first check : AutoGenerateColumns="True" in datagrid.
if you want to do in web services or asp.net places:
XmlDocument xml = new XmlDocument();
xml.LoadXml(response);
XmlNodeList xnList = xml.SelectNodes("/person");
//int[] ids = new int[10];
//string[] str = new string[10];
//int i = 0;
string firstName="", lastName="", headline="";
foreach (XmlNode xn in xnList)
{
firstName = xn["first-name"].InnerText;
lastName = xn["last-name"].InnerText;
headline = xn["headline"].InnerText;
//string url = xn["url"].InnerText;
//Console.WriteLine("Name: {0} {1}", firstName, lastName);
}
XmlDocument will work.
if you want to do in silverlight scree:
first check the result which fields are coming in result.
if you are getting result like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>Damu</first-name>
<last-name>P</last-name>
<headline>--</headline>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile?viewProfile=&key=123089296&authToken=NpQD&authType=name&trk=api*a170167*s178416*</url>
</site-standard-profile-request>
</person>
then we need to print this xml in datagrid:
for this first create on class function in silverlight screen:
public class Person
{
public string firstname { get; set; }
public string lastname { get; set; }
public string headline { get; set; }
public string url { get; set; }
//public Uri sitestandardprofilerequest { get; set; }
}
then :
XDocument xdoc = XDocument.Parse(e.Result);
List<Person> _PersonList = new List<Person>(10);
Person obj = new Person();
string[] a = new string[] { };
int i=0;
var persons = from d in xdoc.Elements("person")
select d;
foreach (var _persons in persons)
{
obj.firstname=_persons.Element("first-name").Value.ToString();
obj.lastname = _persons.Element("last-name").Value.ToString();
obj.headline = _persons.Element("headline").Value.ToString();
obj.url = _persons.Element("site-standard-profile-request").Element("url").Value.ToString();
_PersonList.Add(obj);
i++;
}
dataGrid1.ItemsSource = _PersonList;
you will get the result in grid view.
if you want to do in web services or asp.net places:
XmlDocument xml = new XmlDocument();
xml.LoadXml(response);
XmlNodeList xnList = xml.SelectNodes("/person");
//int[] ids = new int[10];
//string[] str = new string[10];
//int i = 0;
string firstName="", lastName="", headline="";
foreach (XmlNode xn in xnList)
{
firstName = xn["first-name"].InnerText;
lastName = xn["last-name"].InnerText;
headline = xn["headline"].InnerText;
//string url = xn["url"].InnerText;
//Console.WriteLine("Name: {0} {1}", firstName, lastName);
}
XmlDocument will work.
if you want to do in silverlight scree:
first check the result which fields are coming in result.
if you are getting result like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>Damu</first-name>
<last-name>P</last-name>
<headline>--</headline>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile?viewProfile=&key=123089296&authToken=NpQD&authType=name&trk=api*a170167*s178416*</url>
</site-standard-profile-request>
</person>
then we need to print this xml in datagrid:
for this first create on class function in silverlight screen:
public class Person
{
public string firstname { get; set; }
public string lastname { get; set; }
public string headline { get; set; }
public string url { get; set; }
//public Uri sitestandardprofilerequest { get; set; }
}
then :
XDocument xdoc = XDocument.Parse(e.Result);
List<Person> _PersonList = new List<Person>(10);
Person obj = new Person();
string[] a = new string[] { };
int i=0;
var persons = from d in xdoc.Elements("person")
select d;
foreach (var _persons in persons)
{
obj.firstname=_persons.Element("first-name").Value.ToString();
obj.lastname = _persons.Element("last-name").Value.ToString();
obj.headline = _persons.Element("headline").Value.ToString();
obj.url = _persons.Element("site-standard-profile-request").Element("url").Value.ToString();
_PersonList.Add(obj);
i++;
}
dataGrid1.ItemsSource = _PersonList;
you will get the result in grid view.
No comments:
Post a Comment