我想知道是否可以获得相邻节点的值
<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> 这是我用来获取描述内容的查询,但我也想要与描述匹配的链接。
$userIN = "cell";
$nod2 = $xml->xpath
("//description
[text(
[contains
(translate(.,'ABCDEFGHJIKLMNOPQRSTUVWXYZ', 'abcdefghjiklmnopqrstuvwxyz'),
'".$userIN."')]]");发布于 2013-05-02 07:33:35
我借用了另一个主题的答案:
希望这能有所帮助。
$xmlData = new SimpleXMLElement(file_get_contents("data.xml"));
$index = 0;
foreach($xmlData->row as $item) {
if ($item->url == $_GET['id']) {
// show photo
$title = $item->title;
$prev = $xmlData->row[$index-1];
$next = $xmlData->row[$index+1];
}
$index++;
}https://stackoverflow.com/questions/16328068
复制相似问题