2013-02-02 98 views
1

我嘗試從外部網站的html源獲得Yes,,後創建的行v4.0 with A2DP。 在其他情況下v4.0 with A2DP可能有其他的值,但它始終是介乎Yes,,從外部HTML獲取使用兒童()

這是HTML的外部來源:

<tr> 
<td class="ttl"><a href="glossary.php3?term=wi-fi">WLAN</a></td> 
<td class="nfo">Wi-Fi 802.11 a/b/g/n, dual-band, DLNA, Wi-Fi Direct, Wi-Fi hotspot</td> 
</tr> 
<tr> 
<td class="ttl"><a href="glossary.php3?term=bluetooth">Bluetooth</a></td> 
<td class="nfo">Yes, v4.0 with A2DP, LE, EDR</td> 
</tr> 
<tr> 
<td class="ttl"><a href="glossary.php3?term=nfc">NFC</a></td> 
<td class="nfo">Yes</td> 
</tr> 

我使用這個代碼:

<?php 
include_once('/simple_html_dom.php'); 
$dom = file_get_html("http://www.gsmarena.com/pantech_vega_no_6-5268.php"); 
foreach ($dom->find('tr') as $node) { 
if (is_a($node->children(0), 'simple_html_dom_node')) { 
    if ($node->children(0)->plaintext == "Bluetooth") { 
     echo $node->children(1)->plaintext; 
    } 
} 
} 
?> 

而且我得到所有藍牙線路:

Yes, v4.0 with A2DP, LE, EDR 

回答

0

請嘗試更改您的代碼,如下所示:

$plain = explode(',', $node->children(1)->plaintext); 
echo $plain[1];