php - How to ge two fields with one XPath? -
i have xpath gets div want read. how read class , name of div 1 xpath?
<?php $xmldoc = new domdocument(); $xmldoc->load( '<<your file>>>' ); //$xmldoc->loadhtml($sourcestring); //-> if string have $xpath = new domxpath($doc); $elements = $xpath->query("your xpath"); //if sure there 1 div, xpath, can use index 0 in next statement, else uou have itereate in loop $node = $elements->item(0); $attrib1 = $node->attributes->getnameditem("<attribute_name1>"); $attrib2 = $node->attributes->getnameditem("<attribute_name2>"); $attrib3 = $node->attributes->getnameditem("<attribute_name3>"); .... ?>
Comments
Post a Comment