Skip to content

Instantly share code, notes, and snippets.

@patrickcurl
Created August 1, 2013 15:53
Show Gist options
  • Save patrickcurl/6132668 to your computer and use it in GitHub Desktop.
Save patrickcurl/6132668 to your computer and use it in GitHub Desktop.
Gathering all nodes w/ names.
$response =amazonXML('1111837295');
// function that creates xml object from amazon url
// ... $amazonXML = simplexml_load_string(file_get_contents($amazon_url));
// $amazonXML->registerXpathNamespace("xmlns", "http://webservices.amazon.com/AWSECommerceService/2011-08-01");
// return $amazonXML;
$browsenodes = $response->Items->Item->BrowseNodes->children();
var_dump($browsenodes); // see bottom.
//
/*
What I want is an array : categories = ['Instruction Methods', 'Schools & Teaching', 'Education & Reference', 'Subjects', 'Books', 'Pedagogy', 'Schools & Teaching', 'Education & Reference', 'Subjects', 'Books', 'Clinical Psychology', 'Psychology', 'Medical Books', 'Subjects', 'Books', 'Education', 'Administration', 'Counselling', 'Curriculum & instruction', 'Education Philosophy', 'Elementary Education', 'History & Theory', 'Secondary Education', 'Special Education', 'New Used & Rental Textbooks', 'Specialty Boutique', 'Books', 'Clinical Psychology', 'Psychology', 'Social Sciences', 'New, Used, & Rental Textbooks', 'Specialty Boutique', 'Books', 'All Products', 'Products', 'Books', 'Products'];
In otherwords, take ALL ancestors grab any and all name attributes put it into an array, which I'll sift through later.
object(SimpleXMLElement)[299]
public 'BrowseNode' =>
array (size=7)
0 =>
object(SimpleXMLElement)[308]
public 'BrowseNodeId' => string '15959731' (length=8)
public 'Name' => string 'Instruction Methods' (length=19)
public 'Ancestors' =>
object(SimpleXMLElement)[315]
public 'BrowseNode' =>
object(SimpleXMLElement)[316]
public 'BrowseNodeId' => string '5267708011' (length=10)
public 'Name' => string 'Schools & Teaching' (length=18)
public 'Ancestors' =>
object(SimpleXMLElement)[317]
public 'BrowseNode' =>
object(SimpleXMLElement)[318]
public 'BrowseNodeId' => string '21' (length=2)
public 'Name' => string 'Education & Reference' (length=21)
public 'Ancestors' =>
object(SimpleXMLElement)[319]
public 'BrowseNode' =>
object(SimpleXMLElement)[320]
public 'BrowseNodeId' => string '1000' (length=4)
public 'Name' => string 'Subjects' (length=8)
public 'IsCategoryRoot' => string '1' (length=1)
public 'Ancestors' =>
object(SimpleXMLElement)[321]
public 'BrowseNode' =>
object(SimpleXMLElement)[322]
public 'BrowseNodeId' => string '283155' (length=6)
public 'Name' => string 'Books' (length=5)
1 =>
object(SimpleXMLElement)[309]
public 'BrowseNodeId' => string '266137' (length=6)
public 'Name' => string 'Pedagogy' (length=8)
public 'Ancestors' =>
object(SimpleXMLElement)[323]
public 'BrowseNode' =>
object(SimpleXMLElement)[324]
public 'BrowseNodeId' => string '5267708011' (length=10)
public 'Name' => string 'Schools & Teaching' (length=18)
public 'Ancestors' =>
object(SimpleXMLElement)[325]
public 'BrowseNode' =>
object(SimpleXMLElement)[326]
public 'BrowseNodeId' => string '21' (length=2)
public 'Name' => string 'Education & Reference' (length=21)
public 'Ancestors' =>
object(SimpleXMLElement)[327]
public 'BrowseNode' =>
object(SimpleXMLElement)[328]
public 'BrowseNodeId' => string '1000' (length=4)
public 'Name' => string 'Subjects' (length=8)
public 'IsCategoryRoot' => string '1' (length=1)
public 'Ancestors' =>
object(SimpleXMLElement)[329]
public 'BrowseNode' =>
object(SimpleXMLElement)[330]
public 'BrowseNodeId' => string '283155' (length=6)
public 'Name' => string 'Books' (length=5)
2 =>
object(SimpleXMLElement)[310]
public 'BrowseNodeId' => string '11143' (length=5)
public 'Name' => string 'Clinical Psychology' (length=19)
public 'Ancestors' =>
object(SimpleXMLElement)[331]
public 'BrowseNode' =>
object(SimpleXMLElement)[332]
public 'BrowseNodeId' => string '6511980011' (length=10)
public 'Name' => string 'Psychology' (length=10)
public 'Ancestors' =>
object(SimpleXMLElement)[333]
public 'BrowseNode' =>
object(SimpleXMLElement)[334]
public 'BrowseNodeId' => string '173514' (length=6)
public 'Name' => string 'Medical Books' (length=13)
public 'Ancestors' =>
object(SimpleXMLElement)[335]
public 'BrowseNode' =>
object(SimpleXMLElement)[336]
public 'BrowseNodeId' => string '1000' (length=4)
public 'Name' => string 'Subjects' (length=8)
public 'IsCategoryRoot' => string '1' (length=1)
public 'Ancestors' =>
object(SimpleXMLElement)[337]
public 'BrowseNode' =>
object(SimpleXMLElement)[338]
public 'BrowseNodeId' => string '283155' (length=6)
public 'Name' => string 'Books' (length=5)
3 =>
object(SimpleXMLElement)[311]
public 'BrowseNodeId' => string '468224' (length=6)
public 'Name' => string 'Education' (length=9)
public 'Children' =>
object(SimpleXMLElement)[339]
public 'BrowseNode' =>
array (size=8)
0 =>
object(SimpleXMLElement)[341]
public 'BrowseNodeId' => string '491352' (length=6)
public 'Name' => string 'Administration' (length=14)
1 =>
object(SimpleXMLElement)[342]
public 'BrowseNodeId' => string '684254011' (length=9)
public 'Name' => string 'Counseling' (length=10)
2 =>
object(SimpleXMLElement)[343]
public 'BrowseNodeId' => string '491354' (length=6)
public 'Name' => string 'Curriculum & Instruction' (length=24)
3 =>
object(SimpleXMLElement)[344]
public 'BrowseNodeId' => string '684255011' (length=9)
public 'Name' => string 'Educational Philosophy' (length=22)
4 =>
object(SimpleXMLElement)[345]
public 'BrowseNodeId' => string '684256011' (length=9)
public 'Name' => string 'Elementary Education' (length=20)
5 =>
object(SimpleXMLElement)[346]
public 'BrowseNodeId' => string '491366' (length=6)
public 'Name' => string 'History & Theory' (length=16)
6 =>
object(SimpleXMLElement)[347]
public 'BrowseNodeId' => string '684257011' (length=9)
public 'Name' => string 'Secondary Education' (length=19)
7 =>
object(SimpleXMLElement)[348]
public 'BrowseNodeId' => string '491364' (length=6)
public 'Name' => string 'Special Education' (length=17)
public 'Ancestors' =>
object(SimpleXMLElement)[340]
public 'BrowseNode' =>
object(SimpleXMLElement)[349]
public 'BrowseNodeId' => string '465600' (length=6)
public 'Name' => string 'New, Used & Rental Textbooks' (length=28)
public 'Ancestors' =>
object(SimpleXMLElement)[350]
public 'BrowseNode' =>
object(SimpleXMLElement)[351]
public 'BrowseNodeId' => string '2349030011' (length=10)
public 'Name' => string 'Specialty Boutique' (length=18)
public 'Ancestors' =>
object(SimpleXMLElement)[352]
public 'BrowseNode' =>
object(SimpleXMLElement)[353]
public 'BrowseNodeId' => string '283155' (length=6)
public 'Name' => string 'Books' (length=5)
4 =>
object(SimpleXMLElement)[312]
public 'BrowseNodeId' => string '491492' (length=6)
public 'Name' => string 'Clinical Psychology' (length=19)
public 'Ancestors' =>
object(SimpleXMLElement)[354]
public 'BrowseNode' =>
object(SimpleXMLElement)[355]
public 'BrowseNodeId' => string '491490' (length=6)
public 'Name' => string 'Psychology' (length=10)
public 'Ancestors' =>
object(SimpleXMLElement)[356]
public 'BrowseNode' =>
object(SimpleXMLElement)[357]
public 'BrowseNodeId' => string '468214' (length=6)
public 'Name' => string 'Social Sciences' (length=15)
public 'Ancestors' =>
object(SimpleXMLElement)[358]
public 'BrowseNode' =>
object(SimpleXMLElement)[359]
public 'BrowseNodeId' => string '465600' (length=6)
public 'Name' => string 'New, Used & Rental Textbooks' (length=28)
public 'Ancestors' =>
object(SimpleXMLElement)[360]
public 'BrowseNode' =>
object(SimpleXMLElement)[361]
public 'BrowseNodeId' => string '2349030011' (length=10)
public 'Name' => string 'Specialty Boutique' (length=18)
public 'Ancestors' =>
object(SimpleXMLElement)[362]
public 'BrowseNode' =>
object(SimpleXMLElement)[363]
public 'BrowseNodeId' => string '283155' (length=6)
public 'Name' => string 'Books' (length=5)
5 =>
object(SimpleXMLElement)[313]
public 'BrowseNodeId' => string '1288264011' (length=10)
public 'Name' => string 'All Products' (length=12)
public 'Ancestors' =>
object(SimpleXMLElement)[364]
public 'BrowseNode' =>
object(SimpleXMLElement)[365]
public 'BrowseNodeId' => string '1267878011' (length=10)
public 'Name' => string 'Products' (length=8)
public 'IsCategoryRoot' => string '1' (length=1)
public 'Ancestors' =>
object(SimpleXMLElement)[366]
public 'BrowseNode' =>
object(SimpleXMLElement)[367]
public 'BrowseNodeId' => string '1267877011' (length=10)
6 =>
object(SimpleXMLElement)[314]
public 'BrowseNodeId' => string '1294449011' (length=10)
public 'Name' => string 'Books' (length=5)
public 'Ancestors' =>
object(SimpleXMLElement)[368]
public 'BrowseNode' =>
object(SimpleXMLElement)[369]
public 'BrowseNodeId' => string '1267878011' (length=10)
public 'Name' => string 'Products' (length=8)
public 'IsCategoryRoot' => string '1' (length=1)
public 'Ancestors' =>
object(SimpleXMLElement)[370]
public 'BrowseNode' =>
object(SimpleXMLElement)[371]
public 'BrowseNodeId' => string '1267877011' (length=10)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment