I have the following XML (string1):
<?xml version="1.0"?>
<root>
<map>
<operationallayers>
<layer label="Security" type="feature" visible="false" useproxy="true" usePopUp="all" url="http://stackoverflow.com"/>
</operationallayers>
</map>
</root>
And I have this piece of XML (string2):
<operationallayers>
<layer label="Teste1" type="feature" visible="false" useproxy="true" usePopUp="all" url="http://stackoverflow.com"/>
<layer label="Teste2" type="dynamic" visible="false" useproxy="true" usePopUp="all" url="http://google.com"/>
</operationallayers>
I used the funcion simplexml_load_string to import both to the respectives var:
$xml1 = simplexml_load_string($string1);
$xml2 = simplexml_load_string($string2);
Now, I want to replace the node 'operationallayers' of the string1 for the node 'operationallayers' of the string2, but how?
The class SimpleXMLElement does not have a method 'replaceChild' like the DOM has.