XPATH question

Oxygen general issues.
cpaine
Posts: 2
Joined: Thu Oct 26, 2017 10:42 pm

XPATH question

Post by cpaine »

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

I want to search for the @name attribute but extract the uiValue? :?:
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: XPATH question

Post by Radu »

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
Joined: Thu Oct 26, 2017 10:42 pm

Re: XPATH question

Post 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...
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: XPATH question

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