Page 1 of 1
XPATH question
Posted: Thu Oct 26, 2017 10:48 pm
by cpaine
With this xml:
<ns0:properties name="propName" uiValue="12">
I want to search for the @name attribute but extract the uiValue?
Re: XPATH question
Posted: Fri Oct 27, 2017 12:09 am
by Radu
Hi,
Something like this should work:
Code: Select all
//*:properties[@name='propName']/@uiValue
Regards,
Radu
Re: XPATH question
Posted: Fri Oct 27, 2017 3:14 pm
by cpaine
You are right I was not clear in my description.
I would like to search for a certain value of a property name and extract the result of that uiValue only:
So, if:
<ns0:properties name="propName" uiValue="12">
Using something like the following I can't get to work? If I search with a 'propName' and then return 'uiValue' only as a result...
/*/*/*/properties[contains(@name,'propName')]/@uiValue
So the returning value would be 12...
Thank you...
Re: XPATH question
Posted: Sat Oct 28, 2017 11:03 pm
by Radu
Hi,
An XPath expression which starts with "/*/*/*" means that your "properties" element should be searched on the fourth level in the XML document. I consider that it is actually located there.
The problem is probably this part: properties[........... because in the original XML the "properties" element is bound to the prefix "ns0" which is mapped to a namespace, so you can either replace it with *:properties[.... meaning that you are searching for the "properties" element, no matter what namespace it is in, or you can be specific like this ns0:properties[.... as long as your XSLT maps the "ns0" prefix to that precise namespace in which the "properties" element is defined.
Regards,
Radu