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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:56:12+00:00 2026-06-04T22:56:12+00:00

In the application I am working on, there is an XML document that needs

  • 0

In the application I am working on, there is an XML document that needs to be loaded into memory for querying. To do this, I am calling XmlDocument.Load(string path), which has been working fine. However, I recently came across some weird behavior with the method.

I have a generated file that looks like this (edited to remove sensitive data):

*Snip*
<Info name="name2" parent="name1" modifier="A"/>
<Info name="name2" parent="name1" modifier="B"/>
<Info name="name1" modifier="A"/>
<Info name="name1" modifier="B"/>
<Info name="name3" parent="name2" modifier="A"/>
<Info name="name3" parent="name2" modifier="B"/>
*Snip*

Above there are six entries. However, when calling XmlDocument.Load, only 4 entries are loaded, leaving the first 2 entries out. I’ve confirmed this with breakpoints and walking through the data debugger.

However, when I manually rearrange the data in the document to be

*Snip*
<Info name="name1" modifier="A"/>
<Info name="name1" modifier="B"/>
<Info name="name2" parent="name1" modifier="A"/>
<Info name="name2" parent="name1" modifier="B"/>
<Info name="name3" parent="name2" modifier="A"/>
<Info name="name3" parent="name2" modifier="B"/>
*Snip*

all the data is loaded correctly, none of the elements are left out.
As far as I can tell, the document is well formed, and there are no exceptions thrown when loading it. It should also be noted that when I artificially add a parent attribute to all the entries, they all load correctly, but if I understand XML correctly, that shouldn’t matter and it will just nullify missing attributes in code. Also, there are no namespaces specified for any of the elements.

Is this expected behaviour, or am I missing something?
I can give more details if needed.

  • 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-06-04T22:56:13+00:00Added an answer on June 4, 2026 at 10:56 pm

    I just tried your example as such:

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<root><Info name=\"name2\" parent=\"name1\" modifier=\"A\"/><Info name=\"name2\" parent=\"name1\" modifier=\"B\"/><Info name=\"name1\" modifier=\"A\"/><Info name=\"name1\" modifier=\"B\"/><Info name=\"name3\" parent=\"name2\" modifier=\"A\"/><Info name=\"name3\" parent=\"name2\" modifier=\"B\"/></root>");
    int count = doc.SelectNodes("//root/Info").Count;
    

    And it worked fine. It returned a value of 6, which is the correct number. Try it for yourself. If it doesn’t work the same for you, there must be something screwy with your installation. If, however, as I suspect, it does work the same for you, then the problem must be something else.

    Try starting small and adding more complexity until it fails. Either there’s something else wrong in the XML that’s causing it, or there is a bug in the way you’re reading the nodes from the XmlDocument object.

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

Sidebar

Related Questions

I am working on a Web application that needs to send XML to a
In the application I'm working on, there is a function that connects with a
In the application that I am working on, there is tabular data (for the
I'm working on a program that needs to be able to load object-properties from
Working on application that reads emails. Is there a way besides webdav to get
There is a team working on acceptance testing X11 GUI application in our company,
I'm working on a Grails application. There is a domain class participant - within
I'm working with an off-the-shelf application at my company and there is an interesting
I am working on an application/GUI created with Win32/ATL . So there is UI
I've got an application I've been working on. There are projects and employees, projects

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.