Here’s some code I am currently using. Where I need help are $bn_name_search and $bn_id_search
$xpath_base='/ItemSearchResponse/Items/Item[';
for ($i = 1; $i<=10; $i++)
{
$curr_item_base=$xpath_base.$i.']';
$bn_name_search=$curr_item_base.'/BrowseNodes//BrowseNode/Name/text()';
$bn_id_search=$curr_item_base.'/BrowseNodes//BrowseNode/BrowseNodeId/text()';
$bn_names=$parsed->xpath($bn_name_search);
$bn_ids=$parsed->xpath($bn_id_search);
}
This gives me all the browsnode names and all the broswnode ids. What I’d like to do now is find only the browsenode names “BrowseNode/Name/” that are not “All Products” and only browsnode ids “BrowseNode/BrowseNodeId/” share a “BrowseNode/” with a name that is not “All Products” I don’t have to test for the existance of BrowseNode/Name. It won’t be blank if there is an ID. If I can put two negative expressions it would be even better. I would omit those whose names are “All Products” and those whose names are “Departments”
EDIT:
Here’s a block of the XML: Where it says “<Name>Departments</Name>“, I’d like to exclude that name and it’s ID. If I have a similare one that says “<Name>All Products</Name>” I’d also like to exclude that name and it’s ID. (by ID, I mean <BrowseNodeId>)
<BrowseNodes>
<BrowseNode>
<BrowseNodeId>2346727011</BrowseNodeId>
<Name>Casual</Name>
<Ancestors>
<BrowseNode>
<BrowseNodeId>1045024</BrowseNodeId>
<Name>Dresses</Name>
<Ancestors>
<BrowseNode>
<BrowseNodeId>1040660</BrowseNodeId>
<Name>Women</Name>
<Ancestors>
<BrowseNode>
<BrowseNodeId>1036682</BrowseNodeId>
<Name>Departments</Name>
<IsCategoryRoot>1</IsCategoryRoot>
<Ancestors>
<BrowseNode>
<BrowseNodeId>1036592</BrowseNodeId>
<Name>Clothing & Accessories</Name>
</BrowseNode>
</Ancestors>
</BrowseNode>
</Ancestors>
</BrowseNode>
</Ancestors>
</BrowseNode>
</Ancestors>
</BrowseNode>
</BrowseNodes>
There you go: