Error appending element to the dom for a node in the xml

100denari

New Member
I have this xml node\[code\] <event id="e20120630204436"> <title>event stop</title> <source>LiveMass</source> <channel id="0"> <name>Pax TV</name> <onclick/> </channel> <event_site> <name/> <url/> <onclick/> </event_site> <start_date>Sun Jul 01 2012:07/01/2012</start_date> <start_time>10:00 AM</start_time> <end_date>Sun Jul 01 2012</end_date> <end_time>11:00 AM</end_time> <notes/> </event>\[/code\]I retrieve this node and want to append to it new data. I do this with this code:\[code\]$nodes = $xml->xpath("//event[@id='$nodeid']");if ( count($nodes) >= 1 ) { $node = $nodes[0]; }else { return;}$nodedom = dom_import_simplexml($node);$dom = $nodedom->ownerDocument;$xweeks = $dom->createElement("remind_weeks"); $xweeksText = $dom->createTextNode($remind_weeks); $xweeks->appendChild($xweeksText); $xsend_remind = $dom->createElement("send_remind"); $xsend_remind->appendChild($xweeks);$dom->appendChild($xsend_remind);$savedom = $dom->saveXML();$xml = new SimpleXMLElement($savedom);\[/code\]But I get these warnings and then a fatal error for this line \[code\]$xml = new SimpleXMLElement($savedom);\[/code\].\[code\]Warning: SimpleXMLElement::__construct(): Entity: line 233: parser error : Extra content at the end of the document in /Library/WebServer/Documents/Pagelinks_Dev/save_remind.php on line 97Warning: SimpleXMLElement::__construct(): <send_remind><remind_weeks>11</remind_weeks></send_remind> in /Library/WebServer/Documents/Pagelinks_Dev/save_remind.php on line 97Warning: SimpleXMLElement::__construct(): ^ in /Library/WebServer/Documents/Pagelinks_Dev/save_remind.php on line 97Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /Library/WebServer/Documents/Pagelinks_Dev/save_remind.php:97\[/code\]What must I do to fix this error?
 
Back
Top