PHP and javascript snippets you can copy and paste.

Showing posts with label xml php xml_get_isXML(). Show all posts
Showing posts with label xml php xml_get_isXML(). Show all posts

Friday, March 16, 2007

xml_get_isXML($xml)

/**
* xml_get_isXML($xml)
*
* Returns true if a string is valid xml.
* @param $separator - char to separate the string with.
* @param $xml - string.
* Credit: Luis Argerich (lrargerich at yahoo.com)
* @return bool.
*/
function xml_get_isXML($xml){
$parser = xml_parser_create_ns("",'^');
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
if (!xml_parse($parser, $xml, true)) {
return false;
}
xml_parser_free($parser);
return true;
}