Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Problem with SelectNodes [modified]

Problem with SelectNodes [modified]

Scheduled Pinned Locked Moved XML / XSL
questiondatabasexmlhelpannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #1

    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 --

    P 1 Reply Last reply
    0
    • B Brady Kelly

      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 --

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • P pmarfleet

        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

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #3

        See my mod to the message. Thanks anyway.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups