コード例 #1
0
 public XMLReader()
 {
     doc = new XmlDocument();
     doc.Load("../../Test.xml");
     prlg = new Prolog();
     ClassName = new List<string>();
     Struct = new List<string>();
     reqFiles = new List<string>();
 }
コード例 #2
0
        private void parseXML()
        {
            try
            {
                XmlNode docElement = doc.DocumentElement;
                XmlNode decNode = docElement.SelectSingleNode("/Package/Declaration");

                foreach (XmlNode node in decNode.ChildNodes)
                {
                    if (node.Name == "Package")
                        this.PkgName = node.InnerText;
                    else if (node.Name == "class")
                        this.ClassName.Add(node.InnerText);
                    else if (node.Name == "struct")
                        this.Struct.Add(node.InnerText);
                }

                XmlNode prologNode = doc.SelectSingleNode("/Package/ManualPage/Prolog");
                Prolog p = new Prolog();
                foreach (XmlNode node in prologNode.ChildNodes)
                {
                    if (node.Name == "Author")
                        p.Author = node.InnerText;
                    else if (node.Name == "Email")
                        p.EmailID = node.InnerText;
                }
                this.prlg = p;
                XmlNode opsNode = doc.SelectSingleNode("/Package/ManualPage/PackageOps");
                foreach (XmlNode x in opsNode.ChildNodes)
                {
                    this.packageOps += x.InnerText + "\n";
                }
                XmlNode maintNode = doc.SelectSingleNode("/Package/MaintenancePage/ReqFiles");
                String reqForBuilding = "";
                foreach (XmlNode x in maintNode.ChildNodes)
                {
                    this.reqFiles.Add(x.InnerText);
                    reqForBuilding += x.InnerText + " ";
                }
                XmlNode BuildNode = doc.SelectSingleNode("/Package/MaintenancePage/BuildProc");
                this.buildProc = BuildNode.InnerText + " " + reqForBuilding;
                XmlNode verNode = doc.SelectSingleNode("/Package/MaintenancePage/Version");
                this.version = verNode.InnerText;
                XmlNode TestNode = doc.SelectSingleNode("/Package/TestStub");
                this.testStub = TestNode.InnerText;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in XML");
                Console.WriteLine(e.Message);
            }
        }