Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.53 KB

README.md

File metadata and controls

46 lines (31 loc) · 1.53 KB

XPATH

This class is from a video tutorial I did on youtube. It is very simple and should be built upon. I will keep this version the same as the video.

##Basic Example

// Create an instance of XPATH
$path = new XPATH("http://example.com");

// An example query. This will grab all the link href attributes from a page
$links = $path->query("//a/@href");

// loop through and output node values
if($links->length > 0){
    foreach($links as $link) {
        echo $link->nodeValue . "<br>";
    }
}

###Youtube videos on Scraping Websites with Xpath

###More useful Links

I dont usually link to w3fools but they have a nice Xpath syntax reference, even MDN links to it.

Hope you find this useful.

-Nate Wiley

Follow me on Twitter

Add me to a circle G+