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
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.
It's about context. If you get the element at quotes/quote/play, the queries on this node become
I 've done with this. Thank you a lot for your help
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread