עבור לתוכן

c# working with xml צריך עזרה :/

Featured Replies

פורסם

טוב אז יש לי את

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);
}

פורסם
  • מחבר

תודה

האמת שעברתי על הלימוד של xml באתר הזה לפני כמה ימים

אבל לא ניכנסתי ל xpath

:)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים