user3608943
user3608943

Reputation: 1

How to retrieve specific namespace in XML files using Xpath

I do have an XML file that starts as following:

<wfs:WFS_Capabilities xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" ...>

I do have the full xml file in an xsl:variable named="CAPAPILITIES" and the namespace identifier "ogc" in an xsl:variable named "prefix". I tried the following but it does not work:

<xsl:value-of select="$CAPABILITIES/namespace::*[name()='$prefix']" /> 

Upvotes: 0

Views: 48

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122414

and the namespace identifier "ogc" in an xsl:variable named "prefix"

You need to remove the quotes around $prefix:

<xsl:value-of select="$CAPABILITIES/namespace::*[name()=$prefix]" />

in order to compare the namespace node's name() against the value of the prefix variable instead of against the literal string "dollar-prefix".

Upvotes: 1

Related Questions