コード例 #1
0
        /// <summary>
        /// Создаем узел с аттрибутами
        /// </summary>
        /// <param name="name"></param>
        /// <param name="attributes"></param>
        /// <param name="inner_text"></param>
        /// <param name="parent_node"></param>
        public XmlNode CreateNode(string name, Dictionary <string, string> attributes,
                                  string inner_text, XmlNode parent_node)
        {
            try{
                XmlNode node = xml_document.CreateNode(XmlNodeType.Element, name, String.Empty);
                // пройдемся по аттрибутам...
                if (attributes != null)
                {
                    foreach (KeyValuePair <string, string> param in attributes)
                    {
                        XmlAttribute attrib = null;
                        if (param.Key.IndexOf(":") > 0)
                        {
                            attrib = xml_document.CreateAttribute(param.Key, "special_ns");
                        }
                        else
                        {
                            attrib = xml_document.CreateAttribute(param.Key);
                        }
                        attrib.InnerText = param.Value.ToString();
                        node.Attributes.Append(attrib);
                    }
                }
                node.InnerText = inner_text;
                parent_node.AppendChild(node);

                XmlElements.Add((XmlElement)node);
                return(node);
            } catch (XmlException ex) {
                throw new XmlFunException(ex.Message);
            }
        }
コード例 #2
0
 /// <summary>
 /// Создаем узел с аттрибутами
 /// </summary>
 /// <param name="name"></param>
 /// <param name="attributes"></param>
 /// <param name="inner_text"></param>
 /// <param name="parent_node"></param>
 public XmlElement CreateElement(string name, Dictionary <string, string> attributes,
                                 string inner_text, XmlElement parent_element)
 {
     try{
         XmlElement node = xml_document.CreateElement(name);
         // пройдемся по аттрибутам...
         if (attributes != null)
         {
             foreach (KeyValuePair <string, string> param in attributes)
             {
                 XmlAttribute attrib = null;
                 if (param.Key.IndexOf(":") > 0)
                 {
                     attrib = xml_document.CreateAttribute(param.Key.Substring(0, param.Key.IndexOf(":")),
                                                           param.Key.Substring(param.Key.IndexOf(":") + 1, param.Key.Length - param.Key.IndexOf(":") - 1));
                 }
                 else
                 {
                     attrib = xml_document.CreateAttribute(param.Key);
                 }
                 attrib.InnerText = param.Value.ToString();
                 node.Attributes.Append(attrib);
             }
         }
         node.InnerText = inner_text;
         parent_element.AppendChild(node);
         XmlElements.Add(node);
         return(node);
     } catch (XmlException ex) {
         throw new XmlFunException(ex.Message);
     }
 }
コード例 #3
0
 public void FillXmlElements(ExtXmlNode elem)
 {
     Parallel.ForEach(elem.InnerNode.ChildNodes.Cast <XmlNode>(), parallel_options, (el, loop_state) => {
         ExtXmlNode ext_el = new ExtXmlNode(el);
         if (ext_el != null)
         {
             if (!(ext_el.InnerNode is XmlText) &&
                 !(ext_el.InnerNode is XmlDeclaration) &&
                 !(ext_el.InnerNode is XmlWhitespace) &&
                 !(ext_el.InnerNode is XmlSignificantWhitespace))
             {
                 lock (XmlElements) {
                     XmlElements.Add((XmlElement)ext_el.InnerNode);
                 }
                 FillXmlElements(ext_el);
             }
         }
     });
 }
コード例 #4
0
        public void FillXmlElements(XmlDocument doc)
        {
            XmlElements.Clear();
            XmlElements.Add(doc.DocumentElement);
            Parallel.ForEach(doc.DocumentElement.ChildNodes.Cast <XmlNode>(), parallel_options, (el, loop_state) => {
                if (!(el is XmlDeclaration) && !(el is XmlSignificantWhitespace))
                {
                    ExtXmlNode ext_el = new ExtXmlNode(el);
                    if (ext_el != null)
                    {
                        lock ( XmlElements ) {
                            XmlElements.Add((XmlElement)ext_el.InnerNode);
                        }
                        FillXmlElements(ext_el);
                    }
                }
            });

            XmlElements.Sort(_SortFunc);
        }