PHP SimpleXML


From Docunext Technology Wiki

Jump to: navigation, search

Following the example from php.net, I wrote a script using the SimpleXMLElement function:

<?php
$xmlstr = <<<XML <?xml version="1.0" standalone="yes" ?="">
<a>
<b>hello</b>
  <c>by</c>
  <d>
    <e>
      <f>g</f>
    </e>
  </d>
</a>
XML;


$blah = new SimpleXMLElement($xmlstr);

echo $blah->b;

As the name suggests, it is simple! I'm interested in what the SimpleXML object is all about, and whether it can be stored in xcache or memcached. Surprisingly, since memcached serializes objects, SimpleXML objects cannot be cached, because built-in PHP objects cannot be serialized. Hmm. View the "Notes" here.

There appears to be a work around, but I'm not sure if I understand it: http://www.php.net/manual/en/function.simplexml-load-string.php#77868

Actually that wouldn't help because the unserialized data is no longer a simpleXML object.

Personal tools