Reputation: 852
I want to parse using XSLT.
My XML:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:obtenerListaMisionesResponse xmlns:ns2="http://Servicios/">
<return>
<codMisiones>1</codMisiones>
<correoMision>Foo</correoMision>
<nombreMision>Bar</nombreMision>
</return>
<return>
<codMisiones>2</codMisiones>
<correoMision>Foo 2</correoMision>
<nombreMision>Bar 2</nombreMision>
</return>
</ns2:obtenerListaMisionesResponse>
</S:Body>
</S:Envelope>
Then I tried using this XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="obtenerListaMisionesResponse">
<xsl:for-each select="return">
<xsl:value-of select="nombreMision"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
But I have this return:
1 Foo Bar 2 Foo2 Bar2
When I want this:
Bar Bar2
I think is something because my namespace inside, but I dont understand what is wrong.
Upvotes: 0
Views: 46
Reputation: 12075
You are correct, obtenerListaMisionesResponse
is not the same name as ns2:obtenerListaMisionesResponse
, hence your template doesn't match it.
Try matching ns2:obtenerListaMisionesResponse
instead, and include the xmlns:ns2=..
declaration in your XSLT root element.
Upvotes: 1