Page 1 of 1

split an XML to individual nodes using XSLT

Posted: Wed Apr 12, 2017 10:35 am
by abonsey
Hi All,
I'm trying to split a supplied XML to individual orders but can't extract based on a specific field.
Below is my supplied XML
<CudosOrders>
<CudosOrder OrderID="647105">
<OrderReference>276945</OrderReference>
<CustomHeadFields>
<CustomHeadField0><![CDATA[Nicky]]></CustomHeadField0>


Here is the extract from my XSLT. I'm trying to split it based on OrderID but I guess I've coded it wrong.
<xsl:template match="/CudosOrders/CudosOrder/">
<xsl:result-document method="xml" href="{@Type='OrderID'}.xml">
<xsl:copy-of select="." />
</xsl:result-document>
</xsl:template>
...

Any advice??

Thanks

Re: split an XML to individual nodes using XSLT

Posted: Wed Apr 12, 2017 11:30 am
by freddyp
The attribute is called OrderID, not Type, so it should be

Code: Select all

@OrderID
instead of

Code: Select all

@Type='OrderID'

Re: split an XML to individual nodes using XSLT

Posted: Thu Apr 13, 2017 12:52 pm
by abonsey
Hi,
Thanks for that. All working fine now.