Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: appending a new element to an existing xml file

From: ofuuzo1@-----.--
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent