To make a backup copy of XML nodes, I must copy all the node elements to a new node. I have this code to do the copying.
foreach($xurll as $url)
{
$urlid = $url->getAttribute('ID');
$xurl = $dom->createElement("URL");
$xurl->setAttribute("ID", $urlid);
$xurlb->appendChild($xurl);
$name = $url->getElementsByTagName ("NAME")->item(0)->NodeValue;
$xuname = $dom->createElement("NAME");
$xunameText = $dom->createTextNode($name);
$xuname->appendChild($xunameText);
$xurl->appendChild($xuname);
$urllink = $url->getElementsByTagName ("URLC")->item(0)->NodeValue;
$xulink = $dom->createElement("URLC");
$xulinkText = $dom->createTextNode($urllink);
$xulink->appendChild($xulinkText);
$xurl->appendChild($xulink);
}
This code retrieves the id for the URL node to be copied, but doesn’t retrieve the NAME or URLC.
What is the right way to get that information?
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMMUNITIES>
<COMMUNITY ID="c000002">
<NAME>ID000002</NAME>
<TOP>192</TOP>
<LEFT>297</LEFT>
<WIDTH>150</WIDTH>
<HEIGHT>150</HEIGHT>
<URLS>
<URL ID="u000002">
<NAME>Facebook.com</NAME>
<URLC>http://www.facebook.com</URLC>
</URL>
</URLS>
</COMMUNITY>
</COMMUNITIES>
The
NodeValuehere should be lower casenodeValue, try this instead