Source Code:
(back to article)
<?php libxml_use_internal_errors(true); $xml_string = "<root><element>text</element></root>"; $xml = simplexml_load_string($xml_string); $errors = libxml_get_errors(); if (empty($errors)) { //valid xml print "Valid XML"; } else { //Invalid xml print "Invalid XML"; } libxml_clear_errors(); libxml_use_internal_errors(false);
Result:
Report an issue