المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Adding InnerText of Child Nodes having same tags into a list.



C# Programming
07-28-2012, 04:41 PM
Hello I am new to xml. I want to read the data from xml file. Here is my xml code :
Spain Costa Blanca South house 95000 region 2 2 for-saleR214 http://www.solmarestates.com/images/propimages/R2141.jpg http://www.solmarestates.com/images/propimages/R2142.jpg http://www.solmarestates.com/images/propimages/R2143.jpg http://www.solmarestates.com/images/propimages/R2144.jpg http://www.solmarestates.com/images/propimages/R2145.jpg http://www.solmarestates.com/images/propimages/106_1218710541.jpeg http://www.solmarestates.com/images/propimages/106_1218710543.jpeg http://www.solmarestates.com/images/propimages/106_1218710546.jpeg
Now I want to get all photos in a list . I am trying with code :
XmlNode root = PropertyDocument.SelectSingleNode("//overseas_sales"); XmlNodeList nodeList = root.SelectNodes("overseas_sale_ad") ArrayList ElementsList = new ArrayList(); foreach (XmlNode n in nodeList) { if (n.SelectSingleNode("external_id").InnerText == ID) { XmlNodeList photos = n.SelectNodes("photos"); foreach(XmlNode ph in photos) { ElementsList.Add(ph.SelectSingleNode("photo").InnerText); } } }

But I am getting url of only first photo. I want to get them all in "ElementList". Can anyone help?