As a follow up to my earlier question, I'm thinking of using simplexml_load_file
to load an XML file from a URL.
Would it be possible for me to turn that SimpleXML
object to a DOMDocument
object via (DOMDocument)$my_simplexml
?
You can use the dom_import_simplexml
function.
Quoting :
DOMElement dom_import_simplexml ( SimpleXMLElement $node )
This function takes the node node of class
SimpleXML
and makes it into aDOMElement
node. This new object can then be used as a nativeDOMElement
node.
And, just so it's said, the exact opposite manipulation can be done using simplexml_import_dom
.
Well, it's not a "cast" ; it's a function-call... But I guess that would still be OK for your ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With