我可以通过php中的xpath->查询从以下代码中获取数据时间值
<span class="timestamp" data-time="1395846963">33m</span>
答案 0 :(得分:1)
尝试使用DOMDocument和DOMXPath
$str = '<span class="timestamp" data-time="1395846963">33m</span>';
$DOM = new DOMDocument();
$DOM->loadHTML($str);
$XPATH = new DOMXPATH($DOM);
$r = $XPATH->query("//span/@data-time");
var_dump($r->item(0)->nodeValue);