Example #1
0
        public TTNCParser(XmlElement document, bool attrib)
        {
            TTNCParser P;

            this.value_string = "";
            if (document.HasAttributes)
            {
                P = new TTNCParser();

                foreach (XmlAttribute attr in document.Attributes)
                {
                    if (!this.value_dic_List.ContainsKey("@attribute"))
                    {
                        this.value_dic_List["@attribute"] = new List <TTNCParser>();
                    }
                    if (!P.value_dic_List.ContainsKey(attr.Name + ""))
                    {
                        P.value_dic_List[attr.Name + ""] = new List <TTNCParser>();
                    }
                    P.value_dic_List[attr.Name + ""].Add(new TTNCParser(attr.Value + ""));
                    this.value_dic_List["@attribute"].Add(P);
                }
            }

            if (document.HasChildNodes)
            {
                foreach (XmlElement x in document)
                {
                    if (!this.value_dic_List.ContainsKey(x.Name.ToString()))
                    {
                        this.value_dic_List[x.Name.ToString()] = new List <TTNCParser>();
                    }
                    this.value_dic_List[x.Name.ToString()].Add(new TTNCParser(x));
                }
            }
            else
            {
                this.value_string = document.Value;
            }
        }
Example #2
0
        public TTNCParser(XmlElement document)
        {
            this.value_string = "";

            if (document.HasChildNodes)
            {
                try
                {
                    foreach (Object x in document)
                    {
                        if (x is XmlElement)
                        {
                            XmlElement e = (XmlElement)x;
                            TTNCParser P = new TTNCParser(e);
                            if (!this.value_dic_List.ContainsKey(e.Name.ToString()))
                            {
                                this.value_dic_List[e.Name.ToString()] = new List <TTNCParser>();
                            }
                            this.value_dic_List[e.Name.ToString()].Add(P);
                        }
                        else if (x is XmlText)
                        {
                            XmlText t = (XmlText)x;
                            this.value_string = t.Value;
                        }
                    }
                }
                catch (InvalidCastException e)
                {
                    throw e;
                }
            }
            else
            {
                this.value_string = document.Value;
            }
        }