xml - how to select elements when the root element has a lot of attributes -


i have following xml:

<?xml version="1.0" encoding="utf-8"?>  <gbxml version="0.37" usesiunitsforresults="true" volumeunit="cubicmeters" areaunit="squaremeters" lengthunit="meters" temperatureunit="c" xmlns="http://www.gbxml.org/schema" xsi:schemalocation="http://www.gbxml.org/schema xsi.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <campus id="cmps-1"> <location> <name>trois-rivieres, pq canada</name> <latitude>46.210000</latitude> <longitude>-72.350000</longitude> </location> </campus> </gbxml> 

i want select "latitude" value. using below xpath expression not returning anything:

<p><code><xsl:value-of select="gbxml/campus/location/latitude"/></code></p> 

i new in xpath, appreciate if me this

you have default namespace xmlns="http://www.gbxml.org/schema".

in xslt, add namespace, xmlns:text="xmlns="http://www.gbxml.org/schema" (you creating shortcut of default namespace).

add exclude-result-prefixes="text" omit text prefix in output.

then, change:

<p><code><xsl:value-of select="gbxml/campus/location/latitude"/></code></p> 

to

<p><code><xsl:value-of select="text:gbxml/text:campus/text:location/text:latitude"/></code></p> 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -