解析谷歌通讯录 API XML


parsing google contacts api XML

所以我从谷歌获得了以下XML形式的联系数据:

<entry gd:etag='&quot;Q3Y4fDVSLyt7I2A9WhJXFEkDTgY.&quot;'><id>http://www.google.com/m8/feeds/contacts/email/base/24fc18e00ee1c72e</id><updated>2012-08-08T18:18:42.834Z</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-08T18:18:42.834Z</app:edited><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title>Person 1</title><link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/email/24fc18e00ee1c72e'/><link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/email/full/24fc18e00ee1c72e'/><link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/email/full/24fc18e00ee1c72e'/><gd:name><gd:fullName>Person 1</gd:fullName><gd:givenName>Person</gd:givenName><gd:familyName>1</gd:familyName></gd:name><gd:email rel='http://schemas.google.com/g/2005#home' address='person1@person.com' primary='true'/><gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/email/base/6'/></entry><entry gd:etag='&quot;R30zcTVSLyt7I2A9WhJXFEkDTgc.&quot;'><id>http://www.google.com/m8/feeds/contacts/email/base/2c7cd0de89c805cc</id><updated>2012-08-08T18:18:56.389Z</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-08-08T18:18:56.389Z</app:edited><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/><title>Person 2</title><link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/email/2c7cd0de89c805cc'/><link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/email/full/2c7cd0de89c805cc'/><link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/email/full/2c7cd0de89c805cc'/><gd:name><gd:fullName>Person 2</gd:fullName><gd:givenName>Person</gd:givenName><gd:familyName>2</gd:familyName></gd:name><gd:email rel='http://schemas.google.com/g/2005#home' address='person2@person.com' primary='true'/><gContact:groupMembershipInfo deleted='false' href='http://www.google.com/m8/feeds/groups/email/base/6'/></entry>

我将如何使用domdocument在PHP中解析此XML以返回一个漂亮的数组,其中每个条目都将包含该人的头衔,姓名和电子邮件?

我不知道在这种情况下使用哪种 domdocument 方法

学习 DOMXPath。这是你想要的。