|
Subject:
|
append a xml node from one file to another
|
|
Posted By:
|
pravind
|
Post Date:
|
2/18/2006 2:12:44 AM
|
Hi, I have problem to append a node from one XMl to another XML for Eg: File1.xml <?xml version="1.0"?> <services> <service xmlns="" xsi:type="SrvcFlight" id="1"> <flight> <Flno>123</Flno> <Flname>ABCD</Flname> </flight> <customer> <name>Mr. xyz</name> <age>45</age> </customer> </serivce> <service xmlns="" xsi:type="SrvcFlight" id="2"> <flight> <Flno>1234</Flno> <Flname>ABCDX</Flname> </flight> <customer> <name>Mr. lmn</name> <age>45</age> </customer> </serivce> </services> <services>
File2.xml <?xml version="1.0"?> <services> <service xmlns="" xsi:type="SrvcCar" id="1"> <car> <carno>1234</carno> <provider>ABCDX</provider> <type>Ford</type> </car> <customer> <name>Mr. lmn</name> <age>45</age> </customer> </serivce> </services> <services>
As per this Example I want to Append the service Car node from File2.xml To child of services node from File1.xml
is there any solution for this.
|
|
Reply By:
|
mhkay
|
Reply Date:
|
2/18/2006 5:08:17 AM
|
Sure.
<xsl:template match="/"> <services> <xsl:copy-of select="/services/service"/> <xsl:copy-of select="document('file2.xml')/services/service"/> </services> </xsl:template>
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
pravind
|
Reply Date:
|
2/19/2006 11:25:49 PM
|
Hi, Thanks for Reply It works using XSL
But in more on that I want to do it using PHP,and DOMXML or using XPATH.
Is it Possible ?
Regards, Pravin.
|
|
Reply By:
|
pravind
|
Reply Date:
|
2/20/2006 12:32:47 AM
|
Hi, Thanks for Reply It works using XSL
I want TO process these two xml file using PHP and DOMXML, I have installed XSLT libs for PHP .
Can You Please guide me How I use this XSL using PHP.
Regards, Pravin.
quote: Originally posted by mhkay
Sure.
<xsl:template match="/"> <services> <xsl:copy-of select="/services/service"/> <xsl:copy-of select="document('file2.xml')/services/service"/> </services> </xsl:template>
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
mhkay
|
Reply Date:
|
2/20/2006 9:51:09 AM
|
If you want a solution in PHP, then asking the question on an XSLT forum is probably not your best strategy.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|