Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2012-03-16T12:18:37Z by SystemAdmin
SystemAdmin
SystemAdmin
746 Posts
ACCEPTED ANSWER

Pinned topic xpath issue

‏2012-03-15T11:16:02Z |
I have xml structure as:

<root>
<a:abc>
<b:tag1>product_Add</b:tag1>
<c:value>20</c:value>
</a:abc>
</root>

I want to write xpath with local-name() to pick the value of tag <value> when value of <tag1> is "product_Add".
NOTE# i don't want to include namespace in xpath.
Updated on 2012-03-16T12:18:37Z at 2012-03-16T12:18:37Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    746 Posts
    ACCEPTED ANSWER

    Re: xpath issue

    ‏2012-03-16T12:18:37Z  in response to SystemAdmin
    One possible among others (with more or less assumptions on the context and precise hidden conditions) is the following - I put it in a xslt select as illustration:
    
    <xsl:value-of select=
    "descendant-or-self::*[local-name()='value'] [preceding-sibling::*[local-name()=
    'tag1'][normalize-space()=
    'product_Add']]
    " />
    

    A hidden assumption for the above, for instance, is that as long as there is at least one tag1 of that text content, the value tag will be a valid choice. If you want to have more precision on the position of such tag1 of that text content, add a condition (on position) for that purpose.