Question

I have a XmlDocument which is not properly formed

<library>
  <dept>
    <books></books>
    <language></language>
  </dept>
  <dept>
    <lecturer></lecturer>
  </dept>
</library>

I want to do a XmlDocument.SelectSingleNode for 'lecturer' tag.

When I select ChildNodes of <library> tag, I get only <books> and <language> but not <lecturer>. How do I get XmlNode object of tag?

Was it helpful?

Solution

The XML is well formed XML. It would not load into a XmlDocument otherwise.

The only ChildNodes of library are dept nodes.

To get lecturer, you can do the following:

XmlDocument.SelectSingleNode("library/dept/lecturer");

OTHER TIPS

To parse csproj file, use GetElementsByTagName(). I dont know why SelectSingleNode() is not working!

Thank you Sid

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top