amazon mws orders help simplify, flatten xml

Posted by Scott Kramer on Stack Overflow See other posts from Stack Overflow or by Scott Kramer
Published on 2010-03-18T18:08:10Z Indexed on 2010/03/18 18:11 UTC
Read the original article Hit count: 692

Filed under:
|

XDocument doc = XDocument.Load( filename );

            var ele = doc.Elements("AmazonEnvelope")
                            //.Elements("Header")
                            .Elements("Message")
                            .Elements("OrderReport")
                            .Elements("Item")

                              .Select(element => new
                              {
                                  AmazonOrderItemCode = (string)element.Element("AmazonOrderItemCode"),
                                  SKU = (string)element.Element("SKU"),
                                  Title = (string)element.Element("Title"),
                                  Quantity = (string)element.Element("Quantity"),

                              })

                             //.Elements("ItemPrice")
                             //.Elements("Component")

                              //.Select(element => new
                              //{
                             //     Type = (string)element.Element("Type"),
                             //     Amount = (string)element.Element("Amount"),
                             // })


                           .ToList();


            foreach (var x in ele)
            {
                Console.WriteLine(x.ToString());
            }

© Stack Overflow or respective owner

Related posts about amazon

Related posts about Xml