I have the XML below and want to select the value of the name
attribute of element category
.
I looked here and here and here.
I actually want xpath 1.0, so I tried:/result/products/product/*:[local-name() = 'categories']/*:[local-name() = 'category']/@name
Since that didn't work I also just attempted xpath 2.0:/result/products/product/*:categories/*:category/@name
If I remove the namespace prefixes from the source document, the selector /result/products/product/categories/category/@name
returns the correct value.
So, how can I ignore namespaces in my selectors?
<result version="3.0"
xmlns="urn:com:tradedoubler:pf:model:xml:output"
xmlns:ns2="urn:com:tradedoubler:pf:model:xml:common">
<products>
<product>
<ns2:name>MY name</ns2:name>
<ns2:productImage>https://www.google.com/assets/1400x1960/1519833875/18053428-6dv7qPqW.jpg</ns2:productImage>
<ns2:categories>
<ns2:category name="Living>Curtains>Curtains"></ns2:category>
</ns2:categories>
</product>
</products>
</result>