0

I want to be able to retrieve the data on a certain site with the font size="6" I plan on doing this with the xml parser but so far have had no luck. This is my code, if anyone knows where my mistake is, it would be much appreciated.

Thanks

@$doc=new DOMDocument();
@$doc->loadHTML($html4);
    $xml=simplexml_import_dom($doc); // just to make xpath more simple

 $data=$xml->xpath('//font size=6'); 
 $arr= array();
foreach ($data as $img) {

         echo $img;

    }
Teddy13
  • 3,824
  • 11
  • 42
  • 69

1 Answers1

0

Something like:

$doc = new DOMDocument();
$doc->loadHTML($html4);

$xpath = new DOMXpath($doc);

$data = $xpath->query("*/font[@size='6']");
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • it gives me the following Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : font in Entity, line: 1 in /Applications/MAMP/htdocs/retrieve.php on line 326 any suggestions? Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: no name in Entity, line: 1 in /Applications/MAMP/htdocs/retrieve.php on line 326 – Teddy13 Jan 13 '12 at 20:11
  • @Teddy13 You're getting that error because your HTML is not valid XML. Since HTML doesn't necessarily need to be valid XML, the only way to avoid that warning is to change the HTML so that it is valid XML (e.g. XHTML) – Brian Driscoll Jan 13 '12 at 20:14
  • @BrianDriscoll Sorry I am not understanding what you are suggesting. How would you go about retrieving then font size="6"? thanks – Teddy13 Jan 13 '12 at 20:22