2010-09-01 57 views

回答

1

根据我的需要,我会使用xPath和SimpleXml或DOMDocument,尽管Kohana可能会提供Zend与Zend_Dom_Query或Symfony用sfWebBrowser做的更好的事情(两者都可以使用与jQuery的css选择器类似的querys)。总之用简单的XML可能如下所示:

// we will assume you want the images in a div with the id "ihaveimages" 

$dom = new SimpleXmlElement($htmlString); 
$images = $dom->xpath("//div[@id='ihaveimages']/img"); 

foreach($images as $image) 
{ 
    echo $image->asXml(); 
} 

More info on xPath

相关问题