Posted by bleen on 07/18/07 19:53
I'm trying to use SimpleXML but I've run into a conundrum. Every day
an XML file is generated that this script grabs and manipulates. How
can I check that the XML has no problems before creating my
SimpleXMLelement object. Here's what I mean:
// this is the code in question:
$file_topstory = /some/xml/file.xml
$top_story_xml = new SimpleXMLElement($file_topstory, NULL, TRUE);
If the XML doc contains (for example) a URL with an '&' in it then the
script fails. I'd like to do something like this:
if(is_valid_xml($file_topstory)){
$top_story_xml = new SimpleXMLElement($file_topstory, NULL, TRUE);
}else{
// ERROR
}
How can i accomplish this?
[Back to original message]
|