You get an error because the HTML you are loading contains the & character, & is not a valid HTML object. Object Name Flashes:
... <td>HINSON J MARK & WF LOU ANN G</td> ... ^
When loading such documents, you will see an error in these cases (as you wrote):
Warning: DOMDocument :: loadHTMLFile (): htmlParseEntityRef: no name
name refers to the HTML Entity name (link) by template:
&name; ^^^^
However, this error does not cause any problems with the actual loading of this HTML. DOMDocument handles this (general) error perfectly (you may encounter a disconnect in a problematic position ).
So, your assumption that you need to wrap this file in a <body> is incorrect. In HTML, the <body> tag is optional.
Your specific problem was that you could not figure out how to debug the HTML file after it was downloaded. Just use the saveHTML method to output what can be loaded successfully. This would already show you that the URL was loaded successfully.
Which would then lead you to the next point that the Xpath expression was incorrect:
*/div[@class='owner-name']
Although your nose about the <body> was not that far: even this HTML snippet does not contain the <body> , the DOM will receive it! Although these are two tags inside:
bodydiv[@class='owner-name']
Most often, the short form is to use // , which allows you to not specify specifically at what level the depth of the tag is:
//div[@class='owner-name']
See also: