php - Append DOMDocument root element to another DOMDocument -
I have 2 "DOMDocument" objects - $ Original and $ Excess I want to get all the children from an additional docdocument $ And add $ end to the end of the original document.
I had to take the original element of the $ extra document I tried to use: But I get an error, which is expected of Ependon Child as a logon object. I tried to access every child in the document via: But it gives the purpose of domelimity Can you advise how to obtain an object of a domonode class? What is the most convenient way to provide this import operation? The $ basic XML looks like this: $ looks like the additional XML: What do I have to do: A DOMElement is a domonode, the domondode superclass is for element, text and other nodes. There are many child classes here just repeat, import and add them. This also works with document element. $ root = $ Extra-> Document element; $ Original- & gt; Append Child ($ root)
$ extra-> childNodes-> Item (0);
& lt ;? Xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Products & gt; & Lt; RecordReference & gt; 345,345 & lt; / RecordReference> & Lt; NotificationType & gt; 03 & lt; / NotificationType & gt; & Lt; Number of pages & gt; 100 & lt; / NumberOfPages & lt; / Products & gt;
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Products & gt; & Lt; RecordReference & gt; 345,345 & lt; / RecordReference> & Lt; NotificationType & gt; 03 & lt; / NotificationType & gt; & Lt; NumberOfPages & gt; 100 & lt; / NumberOfPages & gt; & Lt; MainSubject & gt; & Lt; SubjectScheme & gt; 10 & lt; / SubjectScheme & gt; & Lt; / MainSubject & gt; & Lt; / Products & gt;
$ targetDom = newdomdocument (); $ TargetDom- & gt; LoadXML ('& lt; root / & gt;'); $ SourceDom = new DOMDocument (); $ SourceDom- & gt; LoadXml ('
$ targetDom = newdomdocument (); $ TargetDom- & gt; LoadXML ('& lt; root / & gt;'); $ SourceDom = new DOMDocument (); $ SourceDom- & gt; LoadXml (' DOMDocument :: importNode () creates a copy of the node given in the context of the document. Only nodes related to a document can be added.
Comments
Post a Comment