-
-
Save daniel-v/008e16b98e0b9484ff17f94c175a7f6a to your computer and use it in GitHub Desktop.
SimpleXML encode/decode ref sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xml = <<<EOF | |
<?xml version="1.0" encoding="utf-8"?> | |
<doc> | |
<test> | |
<You shall do pass> | |
</test> | |
</doc> | |
EOF; | |
$XMLElement = simplexml_load_string($xml); | |
// First test - can I get the same output? | |
echo $XMLElement->asXML(); | |
// Second test - what do I get when I encode? | |
echo (string)$XMLElement->test; | |
// Third test - can I get unencoded contents of test? | |
echo $XMLElement->test->asXML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment