Problem with SelectNodes [modified]
-
Why does this query return only one group node from the given XML? I know it's not the worlds best XML, but this is a very young prototype.
XmlNodeList groupsNodes = sectionXml.SelectNodes("Groups/Group");
<?xml version="1.0" encoding="utf-8" ?>
<Section name="ClientInvoices">
<Groups>
<Group name="Headers" driverQuery="ClientInvoices" destination="XCINVK.TXT">
<Line recordDefinition="InvHeader" />
</Group>
<Group name="Detail" driverQuery="ClientInvoices" groupKey="InvNoSort" destination="XCINVK.TXT">
<Line recordDefinition="DetailFooter" />
<Footer>
<Line recordDefinition="InvDetail" />
</Footer>
</Group>
</Groups>
</Section>[Added 17:38] Sorry, it was a brain fart on my part. I quickly switched to another document to compare operation, and forgot to switch back. I was querying a document with only one group.
Last modified: 29mins after originally posted --
-
Why does this query return only one group node from the given XML? I know it's not the worlds best XML, but this is a very young prototype.
XmlNodeList groupsNodes = sectionXml.SelectNodes("Groups/Group");
<?xml version="1.0" encoding="utf-8" ?>
<Section name="ClientInvoices">
<Groups>
<Group name="Headers" driverQuery="ClientInvoices" destination="XCINVK.TXT">
<Line recordDefinition="InvHeader" />
</Group>
<Group name="Detail" driverQuery="ClientInvoices" groupKey="InvNoSort" destination="XCINVK.TXT">
<Line recordDefinition="DetailFooter" />
<Footer>
<Line recordDefinition="InvDetail" />
</Footer>
</Group>
</Groups>
</Section>[Added 17:38] Sorry, it was a brain fart on my part. I quickly switched to another document to compare operation, and forgot to switch back. I was querying a document with only one group.
Last modified: 29mins after originally posted --
The following code should return an
XmlNodeList
object that contains 2 nodes:XmlDocument sectionXml = new XmlDocument();
sectionXml.Load("sample.xml");
XmlNodeList groupsNodes = sectionXml.SelectNodes("/Section/Groups/Group");Changing the XPath query produced the required output.
Paul Marfleet
-
The following code should return an
XmlNodeList
object that contains 2 nodes:XmlDocument sectionXml = new XmlDocument();
sectionXml.Load("sample.xml");
XmlNodeList groupsNodes = sectionXml.SelectNodes("/Section/Groups/Group");Changing the XPath query produced the required output.
Paul Marfleet
See my mod to the message. Thanks anyway.