123321 And i want to select the value of 123321 And i want to select the value of 123321 And i want to select the value of

Select value of xml document with namespace

291 Views Asked by At

I have the following XML snippet

<aaa>
  <bbb xmlns="http://net.some.address.com">
    <ccc>123321</ccc>
  </bbb>
</aaa>

And i want to select the value of <ccc> with XSL template, but not able to get it by using

<xsl:value-of select="/aaa/bbb/ccc"/>

Any ideas how to get the value without changing the input ?

1

There are 1 best solutions below

0
Tomalak On BEST ANSWER

Declare the namespace and use it.

<xsl:value-of xmlns:a="http://net.some.address.com" select="/aaa/a:bbb/a:ccc"/>
  • You can pick any prefix you want, it does not have to be a.
  • You can declare the namespace at any point higher up in the XSLT document. Usually all namespaces are declared at the <xsl:stylesheet> level, but as you can see, that's just a convention.