Results 1 to 4 of 4

Thread: write the relative location for 2 elements with same name

  1. #1
    Join Date
    Mar 2009

    write the relative location for 2 elements with same name

    My question is related to setting the XPath location for 2 XML elements with the same name, but both of them are not siblings of each other, for example some are ancestor of the other

    Example like this: 1) Quotes/quote/play/title

    If I refer to title like "//title" in <xsl:value-of select = "//title", machine will not figure out which title I am mentioning, 1) or 2)

    So is there other way to write the relative xpath location to refer to the TITLE like in the two absolute location above?

    I don't wanna write long absolute location
    Would you please help me? Thank you

  2. #2
    Join Date
    Mar 2009
    You can use "//play/title" to match (1), and you might use "//scene/title" to match (2).

    If you need to target a specific title, you should be able to use "//play/title[position()=1]" to target the first play title, "//scene/title[position()=4]" to target the fourth scene title, etc.

  3. #3
    Join Date
    May 2007
    It's about context. If you get the element at quotes/quote/play, the queries on this node become
    1) title
    2) sequence/scene/title

  4. #4
    Join Date
    Mar 2009
    I 've done with this. Thank you a lot for your help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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