开发者

XmlDocument SelectSingleNode of improperly formed XML

开发者 https://www.devze.com 2022-12-27 05:28 出处:网络
I have a XmlDocument which is not properly formed <library> <dept> <books></books>

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.

开发者_如何学JAVAWhen I select ChildNodes of <library> tag, I get only <books> and <language> but not <lecturer>. How do I get XmlNode object of tag?


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");


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

Thank you Sid

0

精彩评论

暂无评论...
验证码 换一张
取 消