XPATH question

<oXygen/> general issues.
cpaine
Posts: 2

XPATH question

Thu Oct 26, 2017 10:48 pm

With this xml:
<ns0:properties name="propName" uiValue="12">

I want to search for the @name attribute but extract the uiValue? :?:
Radu
Posts: 5088

Re: XPATH question

Fri Oct 27, 2017 12:09 am

Hi,

Something like this should work:

Code: Select all

//*:properties[@name='propName']/@uiValue


Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
cpaine
Posts: 2

Re: XPATH question

Fri Oct 27, 2017 3:14 pm

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...
Radu
Posts: 5088

Re: XPATH question

Sat Oct 28, 2017 11:03 pm

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 3 guests