03.02.2014 Views

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DOM Extension ” 105<br />

will become the context node and query results will be restricted <strong>to</strong> that node and<br />

its descendants. Otherwise, the root element of the document is assumed <strong>to</strong> be the<br />

context node.<br />

The difference between evaluate and query is that the latter will always return an<br />

instance of DOMNodeList whereas the former will attempt <strong>to</strong> return an appropriately<br />

typed result if only one result is found.<br />

Absolute Addressing<br />

The process of using an XPath expression <strong>to</strong> obtain a set of nodes <strong>to</strong> which that expression<br />

applies is referred <strong>to</strong> as addressing. The remainder of the chapter will cover<br />

various aspects of addressing and related expression syntax.<br />

XPath expressions share several similarities <strong>with</strong> UNIX filesystem paths, both of<br />

which are used <strong>to</strong> traverse conceptual tree structures. See the example below for<br />

specific instances of this. The previous HTML example used <strong>to</strong> illustrate various<br />

concepts of markup languages is reused here <strong>to</strong> showcase XPath addressing.<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!