Apr 14, 2016

클레스 파일 XML파일로 컨버팅 하기

Converting Class File to XML File 
 static void ClassToXml(Args _args)
 {
     SysDictClass sysDictClass  = new SysDictClass(1023902);// used to find the class using classid
     TreeNode    treeNode = TreeNode::findNode(sysDictClass.path()); // to find the class in AOT
     TreeNode    childNode;
     int         counter=1;// used to count No of child nodes in the class
     str         nodename; // used to store the node name
     XmlTextWriter xmlDoc; // used to write xml file
     xmlDoc =XmlTextWriter::newFile("D:\Test.xml"); // creating xml file
     xmlDoc.writeStartDocument(); // writing xml docuemnt starting tag
     xmlDoc.writeStartElement("ClassInformation"); // root node
     xmlDoc.writeAttributeString("ClassName",sysDictClass.name()); // root node attirbutes
     if (treenode) // If  class is avilable
     {
        // info(strfmt('number of methods in a classe: %1',treenode.aotchildnodecount()));
         childnode = treenode.aotfirstchild();
         while(counter <= treenode.aotchildnodecount())
         {
             xmlDoc.writeStartElement("MethodInformation");
             xmlDoc.writeAttributeString("MethodName",childNode.treeNodeName());         
             xmlDoc.writeElementString("MethodContent",childNode.AOTgetSource());
             xmlDoc.writeEndElement();
             childnode = childnode.aotnextsibling(); // gets the next node
             counter++; // increments the counter by 1
         }
     }
     XMLDoc.writeEndElement(); // writes the End Tag
     xmlDoc.writeEndDocument(); // docuemnt ending.
     info("XML File is Created");
 }

No comments:

Post a Comment