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 851429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:25:40+00:00 2026-05-15T07:25:40+00:00

I have a web service that has one method: [WebMethod] public bool SyncUserData(string userxml)

  • 0

I have a web service that has one method:

[WebMethod]
public bool SyncUserData(string userxml)

The xml is a series of user records and I use an XmlReader to read through the data and process it.

When I call the web service with 2000 records, it processes 2000 records.
When my client calls it with the same xml, it processes 1000 records.
It processes every other record.

Does anyone have any experience with this sort of problem?
My thought is that it is an encoding issue but I have tried sending the data to the service as ASCII, ISO-8859-1 etc in my tests and cannot recreate.

Any help much appreciated.

This is the calling code:

while (userXml.Read())
{

    if (userXml.Name == NODE_NAME_FILE_NAME && userXml.NodeType == XmlNodeType.Element)
    {
        _importFilename = userXml.ReadString();
    }

    if (userXml.Name == NODE_NAME_USER && userXml.NodeType == XmlNodeType.Element)
    {
        ProcessUser(userXml);
    }
}

and this is what processUser does with teh xml reader

private void ProcessUser(XmlReader userXml)
{
    _usersinfeed++;
    XmlDocument user = new XmlDocument();
    user.LoadXml(userXml.ReadOuterXml());
     ...

}

  • 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-15T07:25:40+00:00Added an answer on May 15, 2026 at 7:25 am

    What’s biting you is the side-effect of ReadOuterXml – it most likely advances the current position of the XmlReader – but then, in your loop while (userXml.Read()) you advance it again – skipping one xml element in the process.

    There are various ways of solving this – but the easiest and cleanest would be to not use XmlReader. Is that an option?

    An easier way to process xml is Linq to Xml:

    public static void Main()
    {
        SyncUserData(@"
        <doc>
        <filename>test</filename>
        <user>Someone</user>
        <user>Someone2</user>
    
        <filename>testA</filename>
        <user>Someone else</user>
        <user>Someone else2</user>
        </doc>
        ");
    }
    
    const string  NODE_NAME_FILE_NAME = "filename";
    const string  NODE_NAME_USER = "user";
    
    static string _importFilename;
    static int _usersinfeed;
    
    public static bool SyncUserData(string userxml) {
        foreach(XElement el in XDocument.Parse(userxml).Descendants()) {
            //or: XDocument.Parse(userxml).Root.Elements() -- this depends on your document
    
            if (el.Name == NODE_NAME_FILE_NAME)
                _importFilename = el.Value;
            if (el.Name == NODE_NAME_USER)
                ProcessUser(el);
        }
        return true;
    }
    
    private static void ProcessUser(XElement el)
    {
        _usersinfeed++;
        Console.WriteLine("User:{0}, file:{1}\n{2}\n",_usersinfeed,_importFilename,el);
        //you probably don't need the following anymore
        //XmlDocument user = new XmlDocument();
        //user.LoadXml(el.CreateReader());
    
        //...
    }
    

    Which outputs:

    User:1, file:test
    <user>Someone</user>
    
    User:2, file:test
    <user>Someone2</user>
    
    User:3, file:testA
    <user>Someone else</user>
    
    User:4, file:testA
    <user>Someone else2</user>
    

    However, you may be able to use XML Serialization – that’s a very easy way to parse/generate XML without much boilerplate at all also gives you a .NET native datastructure to work with to boot! Then, you just need a small set of classes to define the document structure, and the framework can create instances auto-magically from XML for you, without any manual parsing code whatsoever. Not all XML syntaxes are amenable to that, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 440k
  • Answers 440k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the start attribute: <ol start=6> <li>home</li> <li>place</li> ... </ol>… May 15, 2026 at 5:10 pm
  • Editorial Team
    Editorial Team added an answer You can try $('li a.menu_head').mouseenter(function () { $('ul.menu_body').slideDown('medium'); }); $('ul.main_UL_class_here').mouseleave(function(){… May 15, 2026 at 5:10 pm
  • Editorial Team
    Editorial Team added an answer For the XML fragment that is provided, the following XPath… May 15, 2026 at 5:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.