monkeytooth Posted June 30, 2011 Share Posted June 30, 2011 Ok, I wont lie its been a while since I've parsed any XML files that are more intricate then a simple feed for like lets say a blog.. that said.. <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gContact='http://schemas.google.com/contact/2008' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'><id>[email protected]</id><updated>2011-06-30T00:07:48.706Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'>Chris Hacia's Contacts</title><link rel='alternate' type='text/html' href='http://www.google.com/'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full'/><link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/batch'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full?max-results=5'/><link rel='next' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full?start-index=6&max-results=5'/><author><name>Chris Hacia</name><email>[email protected]</email></author><generator version='1.0' uri='http://www.google.com/m8/feeds'>Contacts</generator><openSearch:totalResults>90</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>5</openSearch:itemsPerPage><entry><id>http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/base/0</id><updated>2010-01-27T00:11:57.430Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'>Chris H</title><link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/0/8_XL_JoAPon1k7SNixI2iA'/><link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/0'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/0'/><link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/0/1264551117430000'/><gd:email rel='http://schemas.google.com/g/2005#other' address='[email protected]' primary='true'/></entry><entry><id>http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/base/1</id><updated>2007-08-01T18:02:04.410Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'></title><link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/1/1B2M2Y8AsgTpgAmY7PhCfg'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/1'/><link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/1/1185991324410001'/><gd:email rel='http://schemas.google.com/g/2005#other' address='[email protected]' primary='true'/></entry><entry><id>http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/base/2</id><updated>2010-01-27T00:11:57.430Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'>Steve Sattler</title><link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/2/1B2M2Y8AsgTpgAmY7PhCfg'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/2'/><link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/2/1264551117430000'/><gd:email rel='http://schemas.google.com/g/2005#other' address='[email protected]' primary='true'/></entry><entry><id>http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/base/3</id><updated>2010-01-27T00:11:57.430Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'>Michael Montana</title><link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/3/1B2M2Y8AsgTpgAmY7PhCfg'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/3'/><link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/3/1264551117430000'/><gd:email rel='http://schemas.google.com/g/2005#other' address='[email protected]' primary='true'/></entry><entry><id>http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/base/4</id><updated>2007-08-01T18:02:04.410Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title type='text'></title><link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/monkeytooth%40gmail.com/4/1B2M2Y8AsgTpgAmY7PhCfg'/><link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/4'/><link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/monkeytooth%40gmail.com/full/4/1185991324410001'/><gd:email rel='http://schemas.google.com/g/2005#other' address='[email protected]' primary='true'/></entry></feed> that is an example of the XML I am trying to parse. And this is how I am attempting to do it.. $doc = new DOMDocument(); $doc->load($result); $arrFeeds = array(); foreach ($doc->getElementsByTagName('feed') as $node) { foreach ($node->getElementsByTagName('entry') as $addy) { $itemRSS = array ('email' => $addy->getElementsByTagName('gd:email')->item(0)->nodeValue); } array_push($arrFeeds, $itemRSS); } array_unique($arrFeeds); I'm not yielding any results from this. All I want to currently do is get the "address=" of the "gd:email" for every "entry" and I am just failing miserably. Any ideas what ive done wrong or have I approached this entirely in a ****ed up way Quote Link to comment https://forums.phpfreaks.com/topic/240754-parsing-this-xml-i-dunno-what-im-doing-wrong/ Share on other sites More sharing options...
monkeytooth Posted June 30, 2011 Author Share Posted June 30, 2011 Is this an impossible task? I know that's a bit of a rhetorical question.. but, Im still stuck tryin to parse this xml Quote Link to comment https://forums.phpfreaks.com/topic/240754-parsing-this-xml-i-dunno-what-im-doing-wrong/#findComment-1236667 Share on other sites More sharing options...
monkeytooth Posted June 30, 2011 Author Share Posted June 30, 2011 Well seeing as help here has been to say the least crappy lately I have gone else where to seek out my answer (not something I typically do as phpfreaks is always my go to... but lately its either snootiness or nothing..) ANYWAY.... http://stackoverflow.com/questions/6530050/php-gmail-contacts-xml-parsing-with-domdocument-and-curl/6530095#6530095 Helped me solve my issues (to some extent..) Quote Link to comment https://forums.phpfreaks.com/topic/240754-parsing-this-xml-i-dunno-what-im-doing-wrong/#findComment-1236700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.