XMLhelper.cs 677 B

1234567891011121314151617181920212223242526272829
  1. using System.Xml;
  2. namespace Common
  3. {
  4. public class XMLhelper
  5. {
  6. public static XmlDocument Xml = new XmlDocument();
  7. public static string GetNode(string nodeNmae)
  8. {
  9. var xn = Xml.SelectSingleNode("root");
  10. if (xn == null)
  11. {
  12. return string.Empty;
  13. }
  14. // 得到根节点的所有子节点
  15. XmlNodeList xnl = xn.ChildNodes;
  16. foreach (XmlNode xn1 in xnl)
  17. {
  18. if (xn1.Name == nodeNmae)
  19. {
  20. return xn1.InnerText;
  21. }
  22. }
  23. return string.Empty;
  24. }
  25. }
  26. }