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 GetText(XmlNode node, string def) { string r = def; XmlNode n = XFunc.GetText(node); if (n != null) { r = n.Value; } return(r); }
public static XmlNode SetAttrs(XmlNode node, params object[] parms) { for (int i = 0; i < parms.Length - 1; i += 2) { if (parms[i] != null && parms[i + 1] != null) { XFunc.SetAttr(node, parms[i].ToString(), parms[i + 1].ToString()); } } return(node); }
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 Guid GetAttr(XmlNode node, string name, Guid def) { Guid guid = def; string s = XFunc.GetAttr(node, name, ""); if (s != "") { guid = new Guid(s); } return(guid); }
public static bool GetAttr(XmlNode node, string name, bool def) { bool r = def; string s = XFunc.GetAttr(node, name, ""); if (s != "") { s = s.ToLower(); r = (s == "1") || (s == "true"); } return(r); }
public static DateTime GetAttr(XmlNode node, string name, DateTime def) { DateTime i = def; string s = XFunc.GetAttr(node, name, ""); if (s != "") { try { i = Convert.ToDateTime(s); } catch { } } return(i); }
public static long GetAttr(XmlNode node, string name, long def) { long i = def; string s = XFunc.GetAttr(node, name, ""); if (s != "") { try { i = Convert.ToInt64(s); } catch { } } return(i); }
public static int GetAttr(XmlNode node, string name, int def) { int i = def; string s = XFunc.GetAttr(node, name, ""); if (s != "") { try { i = Convert.ToInt32(s); } catch { } } return(i); }
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; } } }