SOLVED: DOMDocument->load() Opening and ending tag mismat

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
j0hn
Forum Newbie
Posts: 7
Joined: Sun Jul 01, 2007 7:51 am

SOLVED: DOMDocument->load() Opening and ending tag mismat

Post by j0hn »

I'm getting what appears to me to be some really strange errors. I'm trying to load an XML document from http://banners.willhill.com/xml/viewxml ... B&style=12.

I don't understand the references to p, font, td and tr tags in the error messages, this is an XML file - there are no html tags and I'm sure that the XML file is well formed.

When I run the script on the same file locally it works fine.

Code: Select all

$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->load("http://banners.willhill.com/xml/viewxml.asp?sport=FB&style=12");
Here's the error messages

PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: p line 70 and font in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 71 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: p line 68 and td in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 95 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: p line 67 and tr in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 96 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Entity 'nbsp' not defined in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 98 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: attributes construct error in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 104 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Couldn't find end of Start Tag input line 104 in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 104 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Entity 'nbsp' not defined in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 104 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: font line 63 and table in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 106 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: td line 61 and div in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 107 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: tr line 60 and body in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 110 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Opening and ending tag mismatch: table line 55 and html in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 111 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Premature end of data in tag div line 54 in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 112 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Premature end of data in tag body line 8 in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 112 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12
PHP Warning: DOMDocument::load() [<a href='function.DOMDocument-load'>function.DOMDocument-load</a>]: Premature end of data in tag html line 3 in http://banners.willhill.com/xml/viewxml ... B&style=12, line: 112 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\xml-testing\\parseWillhillXML.php on line 12

line 12 is

Code: Select all

$dom->load("http://banners.willhill.com/xml/viewxml.asp?sport=FB&style=12");


I get the errors with and without

Code: Select all

$dom->preserveWhiteSpace = FALSE;


Any help would be much appreciated.
Last edited by j0hn on Fri Jul 13, 2007 8:37 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: DOMDocument->load() Opening and ending tag mismatch:

Post by volka »

First you get the html page
WILLIAM HILL CREDIT LIMITED
XML FEED SITE - TERMS OF USE
and the dom parser cannot parse that page.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The website checks to see if you have a TOS agreement cookie set before it serves up the XML feeds. You'll need to retrieve the page using cURL or another method that supports sending cookies and then parse the resulting string.
Post Reply