获取XML里指定的节点内容信息

 1     HttpContent bw = new StringContent(StrXml, Encoding.UTF8, "application/Xml");
 2                 var Msg = await _httpClientFactory.CreateClient().PostAsync("http://xxxxx/api/kpbusiness", bw);
 3                 var ss = Msg.Content.ReadAsStringAsync();
 4                 StringReader Reader = new StringReader(ss.Result);
 5                 XmlDocument xmlDoc = new XmlDocument();
 6                 xmlDoc.Load(Reader);
 7                 XmlNodeList topM = xmlDoc.SelectNodes("//business");
 8                 string returncode;
 9                 string returnmsg;
10                 string retappid;
11                 string retid;
12                 foreach (XmlElement element in topM)
13                 {
14                      returncode = element.GetElementsByTagName("returncode")[0].InnerText;
15                      returnmsg = element.GetElementsByTagName("returnmsg")[0].InnerText;
16                      retappid = element.GetElementsByTagName("returncode")[0].InnerText;
17                      retid = element.GetElementsByTagName("returncode")[0].InnerText;
18                 }

 

posted @ 2019-04-30 11:14  ProZkb  阅读(2422)  评论(0编辑  收藏  举报