webserive 用xml写的 登陆方法

前端之家收集整理的这篇文章主要介绍了webserive 用xml写的 登陆方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public string Select(string id,string ps) { //File.WriteAllText("D:/users/anmj/documents/visual studio 2010/Projects/Bill/Bill/123.xml",Encryption.Encrypt(str)); string strpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\XmlData\\UserXml.xml"; XmlDocument doc = new XmlDocument(); #region 验证 try { if (!File.Exists(strpath)) { XmlDeclaration xmldeclaration = doc.CreateXmlDeclaration("1.0","UTF-8","yes"); doc.AppendChild(xmldeclaration); XmlElement xmlelement = doc.CreateElement("Users"); doc.AppendChild(xmlelement); doc.Save(strpath); } doc.Load(strpath); XmlNodeList node = doc.DocumentElement.SelectNodes("User[@ID=\"" + id + "\"]"); if (node.Count > 0) { foreach (XmlNode item in node) { if ((item as XmlElement).GetAttribute("Password") == Encryption.Encrypt(ps)) { Application["User_id"] = (item as XmlElement).GetAttribute("ID"); return "Home.aspx"; } } return "#"; } else return "#"; } catch { return "#"; } #endregion }

猜你在找的XML相关文章