public static string GetAttr(XmlNode node, string name, string def) { string s = def; name = name.ToLower(); if (node != null) { if (node.Attributes != null) { foreach (XmlNode atr in node.Attributes) { if (atr.Name.ToLower() == name) { if (atr.Value != "") { s = atr.Value; } return(s); } } } foreach (XmlNode child in node.ChildNodes) { if (child.Name.ToLower() == name) { return(XFunc.GetText(child, s)); } } } return(s); }
public static string GetChildText(XmlNode node, string child, string def) { foreach (XmlNode n in node.ChildNodes) { if (n.NodeType == XmlNodeType.Element && n.Name == child) { return(XFunc.GetText(n, def)); } } return(def); }
public static string GetText(XmlNode node, string def) { string r = def; XmlNode n = XFunc.GetText(node); if (n != null) { r = n.Value; } return(r); }
public static void SetText(XmlNode node, string val) { XmlNode n = XFunc.GetText(node); if (val == "") { if (n != null) { node.RemoveChild(n); } } else { if (n == null) { n = node.OwnerDocument.CreateTextNode(val); node.AppendChild(n); } else { n.Value = val; } } }