private static void StoreChildNode(SortedList childNodeNames, string nodeName, object nodeValue) { if (nodeValue is XmlElement) { XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = ""; } else if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } } } object oValuesAL = childNodeNames[nodeName]; ArrayList ValuesAL; if (oValuesAL == null) { ValuesAL = new ArrayList(); childNodeNames[nodeName] = ValuesAL; } else { ValuesAL = (ArrayList)oValuesAL; } ValuesAL.Add(nodeValue); }
public static void StoreChildNode(SortedList <string, object> childNodeNames, string nodeName, object nodeValue) { if (nodeValue is XmlElement) { XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = null; } else if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } } } List <object> ValuesAL; if (childNodeNames.ContainsKey(nodeName)) { ValuesAL = (List <object>)childNodeNames[nodeName]; } else { ValuesAL = new List <object>(); childNodeNames[nodeName] = ValuesAL; } ValuesAL.Add(nodeValue); }
private void StoreChildNode(SortedList childNodeNames, string nodeName, object nodeValue) { ArrayList ValuesAL; // Pre-process contraction of XmlElement-s if (nodeValue is XmlElement) { // Convert <aa></aa> into "aa":null // <aa>xx</aa> into "aa":"xx" XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = null; } else if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } } if ((cnode.NextSibling != null && cnode.NextSibling.Name == cnode.Name) || (cnode.PreviousSibling != null && cnode.PreviousSibling.Name == cnode.Name)) { object o = childNodeNames[cnode.ParentNode.Name]; if (o == null) { ValuesAL = new ArrayList(); childNodeNames[cnode.ParentNode.Name] = ValuesAL; } else { ValuesAL = (ArrayList)o; } ValuesAL.Add(nodeValue); return; } } // Add nodeValue to ArrayList associated with each nodeName // If nodeName doesn't exist then add it object oValuesAL = childNodeNames[nodeName]; if (oValuesAL == null) { ValuesAL = new ArrayList(); childNodeNames[nodeName] = ValuesAL; } else { ValuesAL = (ArrayList)oValuesAL; } ValuesAL.Add(nodeValue); }
// StoreChildNode: Store data associated with each nodeName // so that we know whether the nodeName is an array or not. private static void StoreChildNode(SortedList childNodeNames, string nodeName, object nodeValue) { // Pre-process contraction of XmlElement-s if (nodeValue is XmlElement) { // Convert <aa></aa> into "aa":null // <aa>xx</aa> into "aa":"xx" // <aa><![CDATA[xx]]></aa> into "aa":"xx" XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = null; } else { if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } else { if (children.Count == 1 && (children[0] is XmlCDataSection)) { nodeValue = ((XmlCDataSection)(children[0])).InnerText; } } } } } // Add nodeValue to ArrayList associated with each nodeName // If nodeName doesn't exist then add it object oValuesAL = childNodeNames[nodeName]; ArrayList ValuesAL; if (oValuesAL == null) { ValuesAL = new ArrayList(); childNodeNames[nodeName] = ValuesAL; } else { ValuesAL = (ArrayList)oValuesAL; } ValuesAL.Add(nodeValue); }
private static void StoreChildNode(SortedList <string, object> childNodeNames, string nodeName, object nodeValue) { // Pre-process contraction of XmlElements. if (nodeValue is XmlElement) { // Convert <aa></aa> into "aa":null // <aa>xx</aa> into "aa":"xx". XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = null; } else if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } } } // Add nodeValue to ArrayList associated with each nodeName. // If nodeName doesn't exist then add it. List <object> ValuesAL; if (childNodeNames.ContainsKey(nodeName)) { ValuesAL = (List <object>)childNodeNames[nodeName]; } else { ValuesAL = new List <object>(); childNodeNames[nodeName] = ValuesAL; } ValuesAL.Add(nodeValue); }
private void AddToList(SortedList childNodeNames, string nodeName, object nodeValue) { // Pre-process contraction of XmlElement-s if (nodeValue is XmlElement) { // Convert <aa></aa> into "aa":null // <aa>xx</aa> into "aa":"xx" XmlNode cnode = (XmlNode)nodeValue; if (cnode.Attributes.Count == 0) { XmlNodeList children = cnode.ChildNodes; if (children.Count == 0) { nodeValue = null; } else if (children.Count == 1 && (children[0] is XmlText)) { nodeValue = ((XmlText)(children[0])).InnerText; } } } // Add nodeValue to ArrayList associated with each nodeName // If nodeName doesn't exist then add it ArrayList ValuesAL; if (!childNodeNames.Contains(nodeName)) { ValuesAL = new ArrayList(); childNodeNames.Add(nodeName, ValuesAL); } else { ValuesAL = (ArrayList)childNodeNames[nodeName]; } ValuesAL.Add(nodeValue); }