liysd liysd - 1 year ago 194
PHP Question

SimpleXml to string

Is there any function that makes string from PHP simpleXMLElement?

Answer Source

You can use the SimpleXMLElement::asXML() method to accomplish this:

$string = "<element><child>Hello World</child></element>";
$xml = new SimpleXMLElement($string);

// The entire XML tree as a string:
// "<element><child>Hello World</child></element>"

// Just the child node as a string:
// "<child>Hello World</child>"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download