2012-02-14 112 views

回答

2

您可以使用Simple HTML DOM

例子:

cache.txt

<span class="abc">Lorem Ipsum</span> 
<span class="date">THESE</span> 
<span class="def">Dolor sit amet</span> 

file.php

<?php  
include 'simple_html_dom.php';  
$html = file_get_html('cache.txt');  
echo $html->find('span[class=date]',0); //Output: THESE 
?> 
0
**Check this out it will bring the result** 
//cache.txt 
<span class="date">**THESE**</span> 

//index.php 
<?php 
$dom = new DOMDocument(); 
$dom->load('cache.txt'); 
$xml = simplexml_import_dom($dom); 
$data = $xml->xpath('/span'); 
echo $data[0][0]; 
?> 
相關問題