Parsing 如何在C中解析来自GoogleContactsAPI的xml响应#
我正试图通过我的C#应用程序中的Google Contacts API获取联系人列表 下面是我用来提取Google联系人的代码,但不确定解析响应的代码:Parsing 如何在C中解析来自GoogleContactsAPI的xml响应#,parsing,google-api,google-contacts-api,Parsing,Google Api,Google Contacts Api,我正试图通过我的C#应用程序中的Google Contacts API获取联系人列表 下面是我用来提取Google联系人的代码,但不确定解析响应的代码: OAuthGContacts _google = new OAuthGContacts(); if (Request["code"] == null) { Response.Redirect(_google.AuthorizationLinkGet());
OAuthGContacts _google = new OAuthGContacts();
if (Request["code"] == null)
{
Response.Redirect(_google.AuthorizationLinkGet());
}
else
{
//Get the access token and secret.
_google.AccessTokenGet(Request["code"]);
if (_google.Token.Length > 0)
{
string _contactResponse = _google.WebRequest(OAuthGContacts.Method.GET, "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + _google.Token, string.Empty);
XmlReader reader = XmlReader.Create(new StringReader(_contactResponse ));
SyndicationFeed feed = SyndicationFeed.Load(reader);
reader.Close();
}
}
请建议如何解析响应以提取Google联系人。在C#应用程序中获取联系人列表不需要解析任何XML响应。谷歌的数据API提供了这样的功能。这是一个.NET的例子。如果您看到协议,那么只需单击.NET选项卡,您将看到以下代码
public static void PrintAllContacts(ContactsRequest cr)
{
Feed<Contact> f = cr.GetContacts();
foreach (Contact entry in f.Entries)
....
公共静态无效打印所有联系人(ContactsRequest cr)
{
Feed f=cr.GetContacts();
foreach(f.Entries中的联系人条目)
....