V4 GetXmlDocumentByUrl fails when reading web service with xmlns data
I have created a simple web service that sends an arraylist of a data structure.
I can get this using GetXmlDocumentByUrl but cannot iterate through the collection. If I remove the generated xmlns statements manually everything works OK.. I have scanned the net and unable to find a simple way to remove these statements in the web service.
All you need is a little knowledge of namespaces - because of the last xmlns attribute in the XML you're transforming, the elements of the file exists in the http://tempuri.org-namespace, so you'll need to map the namespace-uri "http://tempuri.org/" to a prefix in your XSLT file and use that prefix on the elements you're selecting:
Add the namespace to the <xsl:stylesheet> instruction:
V4 GetXmlDocumentByUrl fails when reading web service with xmlns data
I have created a simple web service that sends an arraylist of a data structure.
I can get this using GetXmlDocumentByUrl but cannot iterate through the collection. If I remove the generated xmlns statements manually everything works OK.. I have scanned the net and unable to find a simple way to remove these statements in the web service.
Thanks for your help
Sample Xml Document
XSLT
<xsl:variable name="xml" select="umbraco.library:GetXmlDocumentByUrl(concat('http://',umbraco.library:RequestServerVariables('HTTP_HOST'),
'/xml dump/test.xml'))"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="$xml/ArrayOfInstitutionListInfo/InstitutionListInfo">
<li><xsl:value-of select="Abbreviation" />test</li>
</xsl:for-each>
</ul>
</xsl:template>
Hi there,
All you need is a little knowledge of namespaces - because of the last xmlns attribute in the XML you're transforming, the elements of the file exists in the http://tempuri.org-namespace, so you'll need to map the namespace-uri "http://tempuri.org/" to a prefix in your XSLT file and use that prefix on the elements you're selecting:
Add the namespace to the <xsl:stylesheet> instruction:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umbraco.library="urn:umbraco.library" xmlns:tmp="http://tempuri.org/" >and then prefix the elements you're selecting:
/Chriztian
Well many thanks Chriztian, this all works fine now. Your prompt reply has really helped me out.. Hope I can return the favour some time
Digby
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.