Writting to external XML using DOM

woodhzoy

New Member
I am trying to write to my XML file but am unsure of the syntax! I am able to open the XML file though. Here is my code so far:\[code\]<?php$doc = new DOMDocument();$doc->load("xml/latestContent.xml");$latestpic = $doc->getElementsByTagName("latestpic");?>\[/code\]I have used a previous method, but this is using the SIMPLE XML, which I no longer want to use:\[code\]<?php$xml = simplexml_load_file("xml/latestContent.xml");$sxe = new SimpleXMLElement($xml->asXML());$latestpic = $sxe->addChild("latestpic");$latestpic->addChild("item", "Latest Pic"); $latestpic->addChild("content", $latestPic);$latestvid = $sxe->addChild("latestvideo");$latestvid->addChild("item", "Latest Video");$latestvid->addChild("content", $videoData);$latestfact = $sxe->addChild("latestfact");$latestfact->addChild("item", "Latest Fact");$latestfact->addChild("content", $factData); $sxe->asXML("xml/latestContent.xml"); ?>\[/code\]How can I make my DOM do the same thing as the SIMPLE method?Thank you in advance!
 
Back
Top