把XML读入流 进行解析XML

 WebRequest request = WebRequest.Create("http://www.all3c.com:8080/StoreAdmin_rebuild/report/all3c_gouok.xml");
       StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.GetEncoding("UTF-8"));
    string xml = reader.ReadToEnd().Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
    XmlDataDocument document = new XmlDataDocument();
    document.LoadXml(xml);
    XmlNodeList list = document.SelectNodes(".//urlset");
    if (list != null)
    {
        foreach (XmlNode node in list)
        {
            string innerText = node.SelectSingleNode(".//ident").InnerText;
            string str3 = node.SelectSingleNode(".//productname").InnerText;
            string str4 = node.SelectSingleNode(".//refprice").InnerText;
            string str5 = node.SelectSingleNode(".//price").InnerText;
            string str6 = node.SelectSingleNode(".//picurl").InnerText;
            string str7 = node.SelectSingleNode(".//url").InnerText;
            string str8 = node.SelectSingleNode(".//shortintro").InnerText;
            string str9 = node.SelectSingleNode(".//browsenode").InnerText;
            string str10 = node.SelectSingleNode(".//pinpai").InnerText;

你可能感兴趣的:(解析xml)