I am writing PHP code that should determine if a given xml is in the format of "atom" or "rss". After observing atom and rss xml files, I decided to classify xml based on the root element. If the root element "<feed"is an xml atom. If it is "<rss"not an atom.
How can I do this check with the DOM? So far I have:
$dom = new DOMDocument();
$dom->loadXML($resp);
$feed = $dom->getElementsByTagName("feed");
if($feed != NULL)
echo 'it\ a atom!';
but it doesn’t work absolutely right .... There are no errors, he just writes "this is an atom", even if it is not
source
share