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. selectSingleNode from a relative position

selectSingleNode from a relative position

Scheduled Pinned Locked Moved XML / XSL
c++tutorialquestion
5 Posts 3 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.
  • M Offline
    M Offline
    mcdirge
    wrote on last edited by
    #1

    Is there a way to specify a search root to selectSingleNode? it always gives me the first hit in the file even if the Node that is calling the function is located after the node that gets found. for example, in file __

    ____1<\Item> __ __

    ____2<\Item> __

    (for some reason the opening Item tags dissapear when i post) How should I Locate Item 2(In c++) without using child or nextsibling pointers(I cant guarantee the order of the child Items)

    N 1 Reply Last reply
    0
    • M mcdirge

      Is there a way to specify a search root to selectSingleNode? it always gives me the first hit in the file even if the Node that is calling the function is located after the node that gets found. for example, in file __

      ____1<\Item> __ __

      ____2<\Item> __

      (for some reason the opening Item tags dissapear when i post) How should I Locate Item 2(In c++) without using child or nextsibling pointers(I cant guarantee the order of the child Items)

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Sorry but that is what selectSingleNode does, return the first node that matches the criteria. You could and the value you are looking for (2) to search string. "forms/form/2" (wrong syntax I know but you get the idea), possibly "forms/form/position() == 2" might work.

      M 1 Reply Last reply
      0
      • N Not Active

        Sorry but that is what selectSingleNode does, return the first node that matches the criteria. You could and the value you are looking for (2) to search string. "forms/form/2" (wrong syntax I know but you get the idea), possibly "forms/form/position() == 2" might work.

        M Offline
        M Offline
        mcdirge
        wrote on last edited by
        #3

        So does that mean there is no search function that allows you to enter a starting point to search from? I'm not familiar with position(). Except that it is XSL and I do not have a stylesheet. Is it possible to use the XSL funtions without that?

        R 1 Reply Last reply
        0
        • M mcdirge

          So does that mean there is no search function that allows you to enter a starting point to search from? I'm not familiar with position(). Except that it is XSL and I do not have a stylesheet. Is it possible to use the XSL funtions without that?

          R Offline
          R Offline
          Ranjan Banerji
          wrote on last edited by
          #4

          Oops. I take my previous posting back :-). You should be able to create an XPATH with the position() function. position is an XPATH function that maybe be used in an XSLT. So you just need to create the correct XPATH. Though position is used when you are in a loop. So using it directly will not help. Instead in your case it would be something like Forms/Form/Item[2] or Forms/Form[2]

          M 1 Reply Last reply
          0
          • R Ranjan Banerji

            Oops. I take my previous posting back :-). You should be able to create an XPATH with the position() function. position is an XPATH function that maybe be used in an XSLT. So you just need to create the correct XPATH. Though position is used when you are in a loop. So using it directly will not help. Instead in your case it would be something like Forms/Form/Item[2] or Forms/Form[2]

            M Offline
            M Offline
            mcdirge
            wrote on last edited by
            #5

            Thanks. that did the job although for the record it was /Form[2]/Item instead of /Form/Item[2]

            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