我使用simpleXML进行xpath查询,我想用它来获取标签标题,描述和链接的节点值。但我不知道如何输出它们就像输出标题内容一样。
<item>
<title>Cell Phone Plans That Make You Go Hmmm</title>
<link>http://www.articlegeek.com/computers/telecommunication_articles/10574- cellphoneplanst.htm</link>
<description>Cell phone plans across the globe vary a great deal. Some say that cell phone plans in the US are more costly. However, there are some advantages to the cell phone plans in the US which may balance the difference.</description>
</item>
function xmlXpath()
{
$xml = xmlParse();
$userIN = "cell";
$nodesT = $xml->xpath("
//*
[
text()
[
contains(
translate(.,'ABCDEFGHJIKLMNOPQRSTUVWXYZ',
'abcdefghjiklmnopqrstuvwxyz'),
'".$userIN."'
)
]
]
");
return $nodesT;
}
答案 0 :(得分:1)
编辑:考虑你的xpath,请执行:
foreach ($nodesT as $nodeT) echo "$nodeT <br />";