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? Quote 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. Quote 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"; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.