java
html
css
mysql
database
linux
xcode
android
regex
objective-c
silverlight
flash
facebook
tsql
apache
mvc
php5
api
postgresql
If you want to get just the node:
BrowserNodes/BrowserNode[Name=_______]/Ancestors/BrowserNode/Name
If you want to get the node's text:
BrowserNodes/BrowserNode[Name=_______]/Ancestors/BrowserNode/Name/text()
In both examples, replace _ with the name for which you are searching.
Find below example:
<?php $xmlString =" <BrowseNodes> <BrowseNode> <Name>Category</Name> <BrowseNodeId>123456</BrowseNodeId> <Ancestors> <BrowseNode> <Name>Whatever</Name> <BrowseNodeId>987654</BrowseNodeId> </BrowseNode> </Ancestors> </BrowseNode> <BrowseNode> <Name>Category</Name> <BrowseNodeId>123456</BrowseNodeId> <Ancestors> <BrowseNode> <Name>Whatever</Name> <BrowseNodeId>987654</BrowseNodeId> </BrowseNode> </Ancestors> </BrowseNode> </BrowseNodes>"; $result= simplexml_load_string($xmlString); $counter =0; $newArray=array(); foreach($result->BrowseNode as $arr) { $newArray[$counter]['Name'] =(string)$arr->Name; $newArray[$counter]['BrowseNodeId'] =(string)$arr->BrowseNodeId; $newArray[$counter]['Ancestors']['Name'] =(string)$arr->Ancestors->BrowseNode->Name; $newArray[$counter]['Ancestors']['BrowseNodeId'] =(string)$arr->Ancestors->BrowseNode->BrowseNodeId; $counter++; } print"<pre>"; print_r($newArray); die; ?>