Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php parse html

$dom = new DOMDocument();
$dom->loadHTMLFile('path/to/htmlfile.html');    // or loadHTML($str)
$dom->load('path/to/xmlfile.xml');              // or loadXML($str)

$table = $dom->getElementById('mytable-id');    // DOMElement
$lines = $table->getElementsByTagName('tr');    // DOMNodeList
$links = $dom->getElementsByTagName('a');

$xpath = new DOMXpath($dom);
$tables = $xpath->query("//table[contains(@class,'mytables-class')]");
 
PREVIOUS NEXT
Tagged: #php #parse #html
ADD COMMENT
Topic
Name
2+4 =