פורסם 2011 בדצמבר 613 שנים טוב אז יש לי את http://lsirwww.epfl.ch/courses/cis/2005ss/exercises/1/bank.xmlאני מצליח להעביר אותו לאוביקת של xmldocument ועכשיו אני צריך " your final task is to loop through its nodes and write out for each node, the name, the value and attributes (if exists)."ואני ממש לא יודע אך לעשות את זהכל החיפושים שלי ב google נותנים דוגמאות של root+child וכאן יש לי bank/accounts/savings_accountsצריך עזרה אך עושים את זה?? XmlDocument newdoc = new XmlDocument(); WebRequest request = WebRequest.Create("[url]http://lsirwww.epfl.ch/courses/cis/2005ss/exercises/1/bank.xml"[/url]); request.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Console.WriteLine(response.StatusDescription); Stream dataStream = response.GetResponseStream(); newdoc.Load(dataStream); XmlElement root = newdoc.DocumentElement; XmlNodeList nodes = root.SelectNodes("/bank"); foreach (XmlNode node in nodes) { string name = root.GetAttribute("customer_account c_id"); string name2 = node["customer_account c_id"].InnerText; string title = node["savings_accounts"].InnerText; // Do whatever you want Console.Write(name); }
פורסם 2011 בדצמבר 613 שנים nodes = root.SelectNodes("descendant::*")זה ישלוף את כל הצאצאים של ה-node הנוכחי (root). ממליץ לך ללמוד את כל מה ש-xpath מספק:http://www.w3schools.com/xpath/default.asp
פורסם 2011 בדצמבר 613 שנים מחבר תודה האמת שעברתי על הלימוד של xml באתר הזה לפני כמה ימים אבל לא ניכנסתי ל xpath
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.