我想使用xpath返回对象内部的param的值。
示例代码:
<object id="player" width="100%" height="100%" type="application/x-shockwave-flash" data="http://merhad.333low.com/player.swf" bgcolor="#000000" name="player" tabindex="0">
<param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="seamlesstabbing" value="true">
<param name="wmode" value="opaque">
<param name="flashvars" value="http://merhad.333low.com/fqoyJxxS-2c2MSx-wGYmS3T1pkggIeiK7wpA7BbXXcK2sC4XYWehpBDV6CAK7CFH/s=awcmxqt5gYntLqHJ9ceP.flv">
</object>
我试过了,但没有结果! 示例代码:
echo $xpath2->query("//object[id='player']/param/@value")->item(0)->nodeValue;
答案 0 :(得分:1)
您应该将ID作为属性进行匹配:
echo $xpath2->query("//object[@id='player']/param/@value")->item(0)->nodeValue;
不过,这只会返回第一个'param'节点值