这是我的结构:
<Users>
<User>
<username>admin</username>
<server>10.xx.xx.xx</server>
<image>images/pic.png</image>
</User>
<User>
<username>bob</username>
<server>10.xx.xx.xx</server>
<image>images/pic2.png</image>
</User>
</Users>
现在我有这段代码可以从节点获取服务器值,该节点具有我正在搜索的特定用户名。
$query = '//Users/User/username[. = "'.$_SESSION['SESS_FIRST_NAME'].'"]';
$entries = $xpath->query($query);
foreach ($entries as $entry) {
//Getting the "server" node value
$server=$entry->nextSibling->nextSibling->nodeValue;
//I wanted to have one more variable here which will save me the image string in the global php variable
$images=$entry->nextSibling->nextSibling->nextSibling->nodeValue; //this is giving me a server value instead of image value
}