Jump to content

Recommended Posts

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?

post-94869-0-33423000-1360818052_thumb.png

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";


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.