http获得web(url)请求,先是获得数据流streamreader,之后将String数据流转换为xmldocument,之后xmlnode读取节点。
// get the responseWebResponse webResponse = webRequest.GetResponse();if (webResponse == null){ return null; }//需要将返回的编码进行指定,指定成默认的即可StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.UTF8);string streamString = sr.ReadToEnd().Trim().Replace("\n", "");//去掉换行符XmlDocument doc = new XmlDocument();doc.LoadXml(streamString);//加载文档XmlNode test1 = doc.SelectSingleNode("returnsms");//根节点string aaa = test1.SelectSingleNode("returnstatus").InnerText;//子节点