Results 1 to 2 of 2

Thread: How do I get finer control with text() or node() functions

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    83

    Unhappy How do I get finer control with text() or node() functions

    Dudes,
    I need to retrieve individual strings from required elements. My xml document is very heavily nested and rather large. I'm starting at the 11th node and digging down further.

    Here is my Xpath query:

    //*[name()='routeObject']//*[name()='eqGroups']//*[name()='type']//text()

    (I have also tried to use node() in place of the text() function but it made no difference)

    There are 21 routeObjects, each with their own heavily nested nodes. This is where I'm trying to dig down. However, when I execute this it returns only the first one, if I use SelectSingleNode. If I use SelectNode I return EVERYTHING I need in the collection. Nevertheless, I would like to get them individually, for example I need to retrieve 5,6,9,13,14,..etc So, for 5 I tried to use position()=5 in this query but with no luck It makes sense to use the position function but I can't get the syntax right. Is this the way to do it?

    Any ideas?


    Thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    83

    Cool Resolved

    Kuwell

    I've sorted it. Here it is:
    //*[name()='routeObject'][position()=5]//*[name()='eqGroups']//*[name()='type']//text()

    or the short hand

    //*[name()='routeObject'][5]//*[name()='eqGroups']//*[name()='type']//text()

    Rock On!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width