2012-08-02 30 views

回答

2

您可以使用DOM文檔來獲得在attributes

$html = '<li data-docid="thisisthevaluetoget" class="search-results-item"></li>'; 
$doc = new DOMDocument; 
$doc->loadHTML($html); 
$nodes = $doc->getElementsByTagName('li'); 
foreach ($nodes as $node) { 
    if ($node->hasAttributes()) { 
     foreach ($node->attributes as $a) { 
      echo $a->nodeName.': '.$a->nodeValue.'<br/>'; 
     } 
    } 
} 
0

您可以使用JavaScript + jQuery來做到這一點。您可以使用$ _GET方法獲取該值並將其傳遞給另一個php文件。

一個例子是here

+0

謝謝blasteralfred但我必須使用PHP DOM解析器它。我會盡力找到其他解決方案。但是,謝謝。 – 2012-08-02 09:13:48