evilsoldier
evilsoldier

Reputation: 163

Select value of xml document with namespace

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 ?

Upvotes: 2

Views: 383

Answers (1)

Tomalak
Tomalak

Reputation: 338158

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.

Upvotes: 5

Related Questions