attaboy Posted February 14, 2013 Share Posted February 14, 2013 I'm trying to learn how to modify xml using simple xml. This is my code: <?php // modifying content $xml = "<root><node1>content</node1></root>"; $sxe = new SimpleXMLElemant($xml); $dom = dom_import_simplexml($sxe); $dom->appendChild(new DOMElement("node2", "content2")); print $sxe->asXML(); ?> This is the error message: Fatal error: Class 'SimpleXMLElemant' not found in C:\xampp\htdocs\Erik_form\modify.php on line 4 Looking at phpinfo() doesn't show me anything useful. I wonder is SimpleXMLElemant() depricated or something? Link to comment https://forums.phpfreaks.com/topic/274470-fatal-error-class-simplexmlelemant-not-found/ Share on other sites More sharing options...
attaboy Posted February 14, 2013 Author Share Posted February 14, 2013 OOPS! I misspelled Element. Link to comment https://forums.phpfreaks.com/topic/274470-fatal-error-class-simplexmlelemant-not-found/#findComment-1412377 Share on other sites More sharing options...
salathe Posted February 14, 2013 Share Posted February 14, 2013 It looks like you're just learning this stuff, so it might be useful to know how to add elements directly with SimpleXML, rather than using the DOM functions. Two available options are: $sxe->addChild("node2", "content2"); $sxe->node2 = "content2"; Link to comment https://forums.phpfreaks.com/topic/274470-fatal-error-class-simplexmlelemant-not-found/#findComment-1412387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.