Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

XPath: selectnodes does not return declaration or comment

$
0
0

In this example:

<?xml version='1.0'?>
  <bookstore xmlns="urn:newbooks-schema">
    <book genre="novel" style="hardcover">
      <title>The Handmaid's Tale</title>
      <author>
        <first-name>Margaret</first-name>
        <last-name>Atwood</last-name>
      </author>
      <price>19.95</price>
    </book>
    <book genre="novel" style="other">
      <title>The Poisonwood Bible</title>
      <author>
        <first-name>Barbara</first-name>
        <last-name>Kingsolver</last-name>
      </author>
      <price>11.99</price>
    </book>
    <book genre="novel" style="paperback">
      <title>The Bean Trees</title>
      <author>
        <first-name>Barbara</first-name>
        <last-name>Kingsolver</last-name>
      </author>
      <price>5.99</price>
    </book>
  </bookstore>

I try to read all nodes with:

 Public Function getAllNodes() As XmlNodeList
         getAllNodes = XDoc.SelectNodes("//*")
         'Is idem:
         'getAllNodes = XDoc.SelectNodes("descendant::*")
 End Function

It works fine, but it does not return the declaration tag nor does it return (in other xml-files) the comment tag.

These tags I get with looping through something like

dim xmlKnoten as xml.xmlnode
For Each xmlKnoten In XDoc.ChildNodes  
Why is this so?


Viewing all articles
Browse latest Browse all 8156