Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:55:48+00:00 2026-05-30T05:55:48+00:00

I am writing a network server in C# .NET 4.0. There is a network

  • 0

I am writing a network server in C# .NET 4.0. There is a network TCP/IP connection over which I can receive complete XML elements. They arrive regularly and I need to process them immediately. Each XML element is a complete XML document in itself, so it has an opening element, several sub-nodes and a closing element. There is no single root element for the entire stream. So when I open the connection, what I get is like this:

<status>
    <x>123</x>
    <y>456</y>
</status>

Then some time later it continues:

<status>
    <x>234</x>
    <y>567</y>
</status>

And so on. I need a way to read the complete XML string until a status element is complete. I don’t want to do that with plain text reading methods because I don’t know in what formatting the data arrives. I can in no way wait until the entire stream is finished, as is often described elsewhere. I have tried using the XmlReader class but its documentation is weird, the methods don’t work out, the first element is lost and after sending the second element, an XmlException occurs because there are two root elements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:55:49+00:00Added an answer on May 30, 2026 at 5:55 am

    Try this:

    var settings = new XmlReaderSettings
    {
        ConformanceLevel = ConformanceLevel.Fragment
    };
    
    using (var reader = XmlReader.Create(stream, settings))
    {
        while (!reader.EOF)
        {
            reader.MoveToContent();
    
            var doc = XDocument.Load(reader.ReadSubtree());
    
            Console.WriteLine("X={0}, Y={1}",
                (int)doc.Root.Element("x"),
                (int)doc.Root.Element("y"));
    
            reader.ReadEndElement();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code to check if there is a network connection present. In a
I'm writing a web application that talks over network socket to a server that
I'm writing TCP/IP code for a DHCP enabled network device. Is there a universal
I'm writing a network app, which sends and receives a lot of different kinds
Hey, I'm writing a network application, in which I read packets of some custom
I am writing an application that needs to send data over a network. I
Im currenty writing a network layer of an iPhone app and accompanying server. The
Abstract Syntax Notation I'm in the process of writing a network client and server,
I'm writing an application that uses a SQL Server 2005 database. In the connection
I'm writing a small game in java. There's a server and a client module.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.