【问题标题】:parsing google contacts api XML解析谷歌联系人api XML
【发布时间】:2012-08-08 18:39:00
【问题描述】:

所以我从谷歌获得了以下混乱的 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 方法适合在这种情况下使用。

【问题讨论】:

    标签: php xml domdocument


    【解决方案1】:

    了解DOMXPath。这就是你想要的。

    【讨论】:

      猜你喜欢
      • 2017-05-11
      • 1970-01-01
      • 2011-07-27
      • 2016-10-08
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 2011-10-09
      • 1970-01-01
      相关资源
      最近更新 更多