Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > How to get xml nested element values in windwos phone?



 

How to get xml nested element values in windwos phone?

 



Topic : 098656

Guest




Hi i need get xml nested element values.i tried some code but i got null reference. so help me how to do this am using my code given below.
Code (XML)
<Categories>
<Category title="curtains" categoryid="1" image="http://123k.com/images/uploads/C/1360922323.png" totalsubcategories="8">
<SubCategory>

<Subcategory name="Childrens Curtains" subcategoryid="3" subimage="http://123.com/images/uploads/S/1364015644.jpg" totalProducts="1"> <Products> <product name="Vintage Pink Pencil Pleat Curtain" id="6"> <Retailers> <Retailername>Curtains and Curtains</Retailername> <Retailername>Amazing Curtains MM</Retailername> </Retailers> <productimage> http://123.com/images/uploads/P/1361354113.jpg </productimage> <productshortdescription> Vintage Pink Pencil Pleat Curtain'Complete the Look'. </productshortdescription> <productprice>13.00</productprice> </product> </Products> </Subcategory>

</Category>

</Categories>

Code (C#)
 XDocument xmlDoc = XDocument.Parse(dataInXmlFile);
                
                var query = from l in xmlDoc.Descendants("Category")
                            select new Class
                            {
                                Titles = l.Attribute("title").Value,
                                Images = l.Attribute("image").Value,
                                ProductCount = l.Attribute("totalsubcategories").Value,
                                Articles = l.Element("SubCategory").Elements("Subcategory")
                                                  .Select(article => new Subclass
                                                  {
                                                      name = article.Attribute("name").Value,
                                                      Subimage = article.Attribute("subimage").Value,
                                                      Product = article.Element("Products").Elements("product")
                                                                     .Select(articles => new Product
                                                                     {
                                                                         Price = articles.Element("productprice").Value,
                                                                        
                                                                         Producttype = articles.Element("Retailers").Elements("Retailerslist")
                                                                                       .Select(retails => new Retailers
                                                                                        {
                                                                                            retailer = retails.Element("Retailername").Value,

                                                                                        }).ToList(),
                                                                         ProductId = articles.Attribute("id").Value,
                                                                         ProductName = articles.Attribute("name").Value,
                                                                         ProductImage = articles.Element("productimage").Value,
                                                                         Shortdescription = articles.Element("productshortdescription").Value
                                                                     }).ToList(),

                                                  })
                                                  .ToList(),

                            };

Code (C#)
[XmlRoot("root")]
    public class Array
    {
        [XmlArray("Categories")]
        [XmlArrayItem("Category")]
        [XmlArrayItem("SubCategory")]
        [XmlArrayItem("Subcategory")]
        [XmlArrayItem("Product")]
        [XmlArrayItem("product")]
        [XmlArrayItem("Retailers")]

        public ObservableCollection<Class> Collection { get; set; }
    }

Code (C#)
public class Class
    {
        public List<SubClass> Articles { get; set; }

       // public string ProductCount { get; set; }

        public string CategoryId { get; set; }

        [XmlAttribute("title")]
        public string Titles { get; set; }

        [XmlAttribute("image")]
        public string Images { get; set; }

        public string name { get; set; }

        public string Subimage { get; set; }

        public string SubcategoryId { get; set; }

        public string ProductName { get; set; }

        public string ProductCount { get; set; }
    }

public class SubClass
    {
        public string name { get; set; }

        public string Subimage { get; set; }

        public string SubcategoryId { get; set; }

        public string ProductName { get; set; }

        public string Producttype { get; set; }

        public string ProductCount { get; set; }

        public string Retailerslist { get; set; }

        public List<Product> Product { get; set; }

    }

public class Product
    {
        public List<Retailers> Producttype { get; set; }

        public string ProductName { get; set; }

        public string ProductImage { get; set; }

        public string Shortdescription { get; set; }

        public string Price { get; set; }

        public string ProductId { get; set; }
    }

public class Retailers
    {
        public string retailer { get; set; }
    }


I tried this code i got null reference value



Tag : Mobile, MySQL, Device (Mobile), C#, Windows Phone, Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-08-03 18:35:53 By : Get xml nested element value View : 995 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Windows Phone and XML Parser







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-07 05:56:54 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : How to get xml nested element values in windwos phone?
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่