3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <book> <section> <p>Example text</p> <p>Another text</p> <img href="imagehref"> <p>Textual content</p> </section> </book>'; $xml = simplexml_load_string($xml); foreach($xml->xpath('/section') as $section) { echo 'Got section', "\n"; foreach($section->children() as $node) { echo $node->getName(), "\n"; } }
based on bWSTX
Output for 7.0.6 - 7.2.0
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Fatal error: Uncaught Error: Call to a member function xpath() on boolean in /in/DBfZe:14 Stack trace: #0 {main} thrown in /in/DBfZe on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.5
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Fatal error: Uncaught Error: Call to a member function xpath() on boolean in /in/DBfZe:14 Stack trace: #0 {main} thrown in /in/DBfZe on line 14
Process exited with code 255.
Output for 5.6.8 - 5.6.12, 5.6.21 - 5.6.28
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Fatal error: Call to a member function xpath() on boolean in /in/DBfZe on line 14
Process exited with code 255.
Output for 5.6.13 - 5.6.20
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Fatal error: Call to a member function xpath() on boolean in /in/DBfZe on line 14
Process exited with code 255.
Output for 5.5.24 - 5.5.28, 5.5.35
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Warning: simplexml_load_string(): </book> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Fatal error: Call to a member function xpath() on a non-object in /in/DBfZe on line 14
Process exited with code 255.
Output for 5.3.21 - 5.4.45, 5.5.29 - 5.5.34
Warning: simplexml_load_string(): Entity: line 8: parser error : Opening and ending tag mismatch: img line 6 and section in /in/DBfZe on line 13 Warning: simplexml_load_string(): </section> in /in/DBfZe on line 13 Warning: simplexml_load_string(): ^ in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Opening and ending tag mismatch: section line 3 and book in /in/DBfZe on line 13 Warning: simplexml_load_string(): Entity: line 9: parser error : Premature end of data in tag book line 2 in /in/DBfZe on line 13 Fatal error: Call to a member function xpath() on a non-object in /in/DBfZe on line 14
Process exited with code 255.