I am trying to learn how to work with xPath and PHP by loading a simple URL as a DOM object and querying the DOM using xPath. I have been running in to a lot of trouble and have been trying to troubleshoot these warnings messages for quite a while now with no success.
I appreciate any suggestions as to why this happening.
Many thanks in advance!
PHP
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile("http://n5a.software.com/calendar/da2013/profile.php?__id=691");
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//ul[@class='flper']/li[2]");
if (!is_null($elements)) {
foreach ($elements as $element) {
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
?>
Output
Warning: DOMDocument::loadHTMLFile(): Attribute style redefined in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 92 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): htmlParseEntityRef: expecting ';' in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 101 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Attribute cellspacing redefined in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 109 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : span in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 165 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : script in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 166 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): htmlParseEntityRef: no name in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 197 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : td in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 205 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : tr in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 230 in C:\xampp\htdocs\www\test\xpath.php on line 3
Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : table in http://n5a.software.com/calendar/da2013/profile.php?__id=691, line: 231 in C:\xampp\htdocs\www\test\xpath.php on line 3