예제 #1
0
파일: BML.cs 프로젝트: crc32a/AlienBML
            public bool ReadXML(string str_name, string str_value)
            {
                Name  = new AlienString.Ref(str_name, true);
                Value = new AlienString.Ref(AlienString.DecodeXml(str_value), true);

                return(true);
            }
예제 #2
0
파일: BML.cs 프로젝트: crc32a/AlienBML
            public bool ReadXML(XmlElement ele, u32 depth)
            {
                bool valid = true;

                Depth = depth;
                Text  = new AlienString.Ref(ele.Name, true);

                if (ele.HasAttributes)
                {
                    if (ele.Attributes.Count > 0xFF)
                    {
                        Console.WriteLine("Too many attributes for {0}", Text.value);
                        valid = false;
                        return(valid);
                    }

                    foreach (XmlAttribute attr in ele.Attributes)
                    {
                        Attribute a = new Attribute();
                        a.ReadXML(attr.Name, attr.Value);
                        Attributes.Add(a);
                    }
                }

                if (ele.HasChildNodes)
                {
                    // inner text is treated as a special text node, so it has children.. (YIKES)

                    foreach (XmlNode xnode in ele.ChildNodes)
                    {
                        // special parser requirements

                        switch (xnode.NodeType)
                        {
                        case XmlNodeType.Element:

                            XmlElement child = (xnode as XmlElement);

                            Node nchild = new Node();

                            valid &= nchild.ReadXML(child, depth + 1);

                            if (valid)
                            {
                                Nodes.Add(nchild);
                            }

                            break;

                        case XmlNodeType.Text:

                            Inner = new AlienString.Ref(AlienString.DecodeXml(xnode.Value), false);
                            End2  = new AlienString.Ref("\r\n", false);

                            break;

                        case XmlNodeType.Comment:

                            // Could be added as Inner/End2, but not required
                            Console.WriteLine("Found XML comment - skipping it");

                            break;

                        default:
                            Console.WriteLine("XmlNodeType not handled - skipping it");
                            break;
                        }
                    }
                }

                bool last_child = !HasElementSibling(ele);

                Fixup(last_child);

                return(valid);
            }