View Single Post
Old 03-08-2012, 04:30 PM  
nm_
Confirmed User
 
Industry Role:
Join Date: May 2011
Location: San Diego
Posts: 328
i suck at remembering regex, so i always use dom->xpath queries instead. you could find the tag with a query something like this:

<?php

$dom = new DOMDocument();

$dom->loadHTML(HTMLHERE);

$xpath = new DOMXpath($dom);

$selectH1 = $xpath->query('//h1[@class="classnamehere"]');

?>

just came up with that right now, so dunno if that's the exact syntax, but i prefer traversing html w/ dom rather than regex

this is a good xpath query guide: http://www.earthinfo.org/xpaths-with-php-by-example/
nm_ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote