How to include an existing XML file in a created DOMDocument



I create a new XML File with DOMDocument in PHP. That works fine. In between the document I want to add an already created XML File. How can I do this?


Existing XML Document:



<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<magazine id="0" time="2014-02-18T14:42:06.0Z" type="0">New magazine</magazine>
</book>
</books>


With the DOM functions of PHP I create another XML file. This works fine. Now I load the file above and create a fragement with:



$fragement = $document->createDocumentFragment();
$fragement->appendXML($this->xmlparser);


But now I dont know how to add the fragment to my document. I tried:



$document->documentElement->appendChild($fragement);


This has no effect on my XML Document.


No comments:

Post a Comment