public Pcity GetCityByCode(string xmlurl, string fcode, string code) { Pcity pc = new Pcity(); XmlDocument xdd = new XmlDocument(); xdd.Load(xmlurl); XmlReader dr = new XmlNodeReader(xdd); while (dr.Read()) { if (dr.NodeType == XmlNodeType.Element) { if (dr.Name == "city") { if (dr.MoveToAttribute("fcode")) { if (dr.Value == fcode) { pc.Fcode = dr.Value; if (dr.MoveToAttribute("code")) { if (dr.Value == code) { pc.Code = dr.Value; if (dr.MoveToAttribute("name")) { pc.Name = dr.Value; return(pc); } } } } } } } } return(pc); }
public List <Pcity> ReadCity(string xmlurl, string fcode) { List <Pcity> provinceList = new List <Pcity>(); XmlDocument xdd = new XmlDocument(); xdd.Load(xmlurl); XmlReader dr = new XmlNodeReader(xdd); while (dr.Read()) { if (dr.NodeType == XmlNodeType.Element) { if (dr.Name == "city") { Pcity pr = new Pcity(); if (dr.MoveToAttribute("fcode")) { if (dr.Value == fcode) { if (dr.MoveToAttribute("name")) { pr.Name = dr.Value; } if (dr.MoveToAttribute("code")) { pr.Fcode = fcode; pr.Code = dr.Value; provinceList.Add(pr); } } } } } } return(provinceList); }