Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: xml parsing >Thread Next - Re: xml parsing Re: xml parsingTo: NULL Date: 5/15/2008 12:15:00 PM On 14 Mag, 18:29, Martin Honnen <mahotr...@yahoo.de> wrote:
> beppe85 wrote:
> > Following your advice i've tried with this:
>
> > IEnumerable<Customer> DisplayQuery(string xmlContent)
> > {
> > XNamespace xmlns = "http://www.w3.org/2005/Atom";
> > XDocument xml = XDocument.Parse(xmlContent);
> > var customers = from customer in xml.Descendants(xmlns +
> > "entry")
> > select new Customer
> > {
> > SalesOrderID =
> > (int)customer.Attribute(xmlns + "SalesOrderID"),
> > Nome =
> > (string)customer.Attribute(xmlns + "Nome"),
>
> The entry elements in an Atom feed do not have any attributes named
> SalesOrderID or Nome. I think what you are looking for with your code is
> the content child elements which then has child elements of that name e.g.
>
> XNamespace atom = "http://www.w3.org/2005/Atom";
> XNamespace ads = "http://schemas.microsoft.com/ado/2007/08/dataweb";
>
> IEnumerable<Customer> DisplayQuery(string xmlContent)
> {
> XNamespace atom = "http://www.w3.org/2005/Atom";
> XNamespace ads = "http://schemas.microsoft.com/ado/2007/08/dataweb";
>
> XDocument xml = XDocument.Parse(xmlContent);
> var customers = from entry in xml.Descendants(atom +
> "entry")
> select new Customer
> {
> SalesOrderID =
> (int)entry.Element(atom + "content").Element(ads + "SalesOrderID"),
> Nome =
> (string)entry.Element(atom + "content").Element(ads + "Nome"),
>
> and so on for the other elements.
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
IT WORKS! THANK YOU VERY MUCH! Is it possible to generalize the
process so i could for example display the content of another table
and not only Customer?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
