Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: appending a new element to an existing xml file [Thread Next] Re: appending a new element to an existing xml fileTo: NULL Date: 3/7/2008 3:31:00 AM On 5 Mar, 15:19, Martin Honnen <mahotr...@yahoo.de> wrote: > ofuu...@yahoo.no wrote: > > I have nth xml files and I want to put all of them together in one xml > > file called new.xml. How can I do it? > > XSLT can do that. You will need to decide however on a new root element > for the elements of those XML documents you want to combine into one > document. > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/ Thanks. The new xml file does not need a new root element. All what I want is to transform each xml file and store all of them in a new xml file. I need help on how I can store the new.xml in a variable, concatenate "new.xml" and "nth_old.xml" and then store it back as "new.xml". This is what I have done: <?php for ($i = 0; $i < 50) { /* load the xml file and stylesheet as dom documents */ $xsl = new DomDocument(); $xsl->load("transform.xsl"); $old = $i."old.xml"; $inputdom = new DomDocument(); $inputdom->load($old); /* create the processor and import the stylesheet */ $proc = new XsltProcessor(); $xsl = $proc->importStylesheet($xsl); /* transform and output the xml document */ $newdom = $proc->transformToDoc($inputdom); print $newdom->saveXML(); print $newdom->save("new.xml"); } ?> Ofuuzo | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
