예제 #1
0
        public static void Main(String[] args)
        {
            // instantiate VTDGen and XMLModifier
            VTDGen      vg  = new VTDGen();
            XMLModifier xm  = new XMLModifier();
            AutoPilot   ap  = new AutoPilot();
            AutoPilot   ap2 = new AutoPilot();

            ap.selectXPath("(/*/*/*)[position()>1 and position()<4]");
            ap2.selectXPath("/*/*/*");
            if (vg.parseFile("soap2.xml", true))
            {
                VTDNav vn = vg.getNav();
                xm.bind(vn);
                ap2.bind(vn);
                ap.bind(vn);
                ap2.evalXPath();
                ElementFragmentNs ef = vn.getElementFragmentNs();
                int i = -1;
                while ((i = ap.evalXPath()) != -1)
                {
                    xm.insertAfterElement(ef);
                }
                xm.output("new_soap.xml");
            }
        }
예제 #2
0
 public AppCoordinator(AppForm appForm)
 {
     _appForm = appForm;
     keyboardMouseSimulator   = new KeyboardMouseSimulator(this);
     cursorIconManager        = new CursorIconManager(this);
     xmlModifier              = new XMLModifier(this);
     hexListener              = new HexListener(this);
     userCommandsListener     = new UserCommandsListener(this);
     mouseEventListener       = new MouseEventListener(this);
     mouseCoordinator         = new MouseCoordinator();
     recordWindowErrorHandler = new RecordWindowErrorHandler(this);
     this.textToSpeech        = new TextToSpeechHelper();
     javaKiller = new JavaKiller();
     hexWindow  = new HexWindow(this);
 }
예제 #3
0
파일: update.cs 프로젝트: zanyants/vtd-xml
 static void Main(string[] args)
 {
     try
     {
         // open a file and read the content into a byte array
         VTDGen vg = new VTDGen();
         if (vg.parseFile("./oldpo.xml", true))
         {
             VTDNav vn = vg.getNav();
             System.IO.FileInfo f1 = new System.IO.FileInfo("./newpo.txt");
             System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);
             
             AutoPilot ap = new AutoPilot(vn);
             XMLModifier xm = new XMLModifier(vn);
             ap.selectXPath("/purchaseOrder/items/item[@partNum='872-AA']");
             int i = -1;
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.remove();
                 xm.insertBeforeElement("<something/>\n");
             }
             ap.selectXPath("/purchaseOrder/items/item/USPrice[.<40]/text()");
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.updateToken(i, "200");
             }
             xm.output(fos);
             fos.Close();
         }
     }
     catch (NavException e)
     {
         Console.WriteLine(" Exception during navigation " + e);
     }
     catch (ModifyException e)
     {
         Console.WriteLine(" Modify exception occurred " + e);
     }
     catch (System.IO.IOException e)
     {
         System.Console.Out.WriteLine(" IO exception condition" + e);
     }
 }
예제 #4
0
        public static void Main(String[] args)
        {
            String   xml = "<aaaa> <bbbbb> <ccccc> </ccccc> <ccccc/> <ccccc></ccccc> </bbbbb> </aaaa>";
            Encoding eg  = Encoding.GetEncoding("utf-8");
            VTDGen   vg  = new VTDGen();

            vg.setDoc(eg.GetBytes(xml));
            vg.parse(false);
            VTDNav    vn = vg.getNav();
            AutoPilot ap = new AutoPilot(vn);

            ap.selectXPath("//*");
            XMLModifier xm = new XMLModifier(vn);

            while (ap.evalXPath() != -1)
            {
                xm.updateElementName("d:/lalalala");
            }
            xm.output("lala.xml");
        }
예제 #5
0
        //make a list of hexes
        //change counter to last element of list 1
        //make a list of non hexes
        //migrate this boths lists and put the non hexed at the end. set them to be papakeynode

        internal XmlNode GetModifiedList(XMLModifier xMLModifier, XmlNode papaKeyNode)
        {
            List <XmlNode> hexedList      = new List <XmlNode>();
            List <XmlNode> emptyHexedList = new List <XmlNode>();

            foreach (XmlNode keyNode in papaKeyNode.ChildNodes)
            {
                if (!keyNode.InnerText.Equals(""))
                {
                    hexedList.Add(keyNode.CloneNode(true));
                }
                else
                {
                    emptyHexedList.Add(keyNode.CloneNode(true));
                }
            }

            if (emptyHexedList.Count == 0)
            {
                return(null);
            }



            xMLModifier.SetNodeIdx(hexedList.Count);
            papaKeyNode.RemoveAll();

            foreach (XmlNode keyXmlNode in hexedList)
            {
                papaKeyNode.AppendChild(keyXmlNode.CloneNode(true));
            }

            foreach (XmlNode keyXmlNode in emptyHexedList)
            {
                papaKeyNode.AppendChild(keyXmlNode.CloneNode(true));
            }

            return(papaKeyNode);
        }
예제 #6
0
 public void TestInitialize()
 {
     Document  = new XDocument(new XElement("Hierarchy"));
     underTest = new XMLModifier(Document);
 }