technosophos / querypath

QueryPath is a PHP library for manipulating XML and HTML. It is designed to work not only with local files, but also with web services and database resources.
http://querypath.org
Other
822 stars 114 forks source link

UnCaught Exception #92

Closed scopium closed 11 years ago

scopium commented 11 years ago

took this example from the API documentation.

$url = 'http://technosophos.com'; print qp($url, 'title')->text();

and this error is generated

PHP Fatal error: Uncaught exception 'QueryPath\ParseException' with message 'DOMDocument::load(): Entity 'nbsp' not defined in http://technosophos.com, line: 409 (/Users/shahinm/Documents/git/QueryPath/src/QueryPath/DOMQuery.php: 3781)' in /Users/shahinm/Documents/git/QueryPath/src/QueryPath/ParseException.php:42 Stack trace:

0 [internal function]: QueryPath\ParseException::initializeFromError(2, 'DOMDocument::lo...', '/Users/shahinm/...', 3781, Array)

1 /Users/shahinm/Documents/git/QueryPath/src/QueryPath/DOMQuery.php(3781): DOMDocument->load('http://technoso...', 0)

2 /Users/shahinm/Documents/git/QueryPath/src/QueryPath/DOMQuery.php(173): QueryPath\DOMQuery->parseXMLFile('http://technoso...', NULL, NULL)

3 /Users/shahinm/Documents/git/QueryPath/src/QueryPath.php(158): QueryPath\DOMQuery->__construct('http://technoso...', 'title', Array)

4 /Users/shahinm/Documents/git/QueryPath/src/qp.php(204): QueryPath::with('http://technoso...', 'title', Array)

5 /Users/shahinm/Documents/netbeans/10355/index.php(14): qp('http://tech in /Users/shahinm/Documents/git/QueryPath/src/QueryPath/ParseException.php on line 42

obviously u can ignore my folder path bu you can see the code is probably not rendering nbsp correctly

scopium commented 11 years ago

I found out why.. when making dom requests.. We need to use htmlqp() no qp(). please update your documentation to reflect that =)

GDmac commented 11 years ago

Querypath API documentation mentions the difference

"htmlqp(): A specialized version of qp() for dealing with poorly formatted HTML." http://api.querypath.org/docs/

technosophos commented 11 years ago

Sorry for this long delay. I didn't see this issue when it was filed. I made a change to the documentation to clear this up.