Menu

Get orig XML from VTD+XML byte array

Help
2008-08-18
2013-05-15
  • Mark Stuppy

    Mark Stuppy - 2008-08-18

    I am trying to get the original XML out of a VTD+XML bytearray but I'm getting the wrong data.  The output of dumpXML() has what appears to be data from the index tacked on to the front.  Here's the example code:

        //Build VTD+XML index
        VTDGen gen = new VTDGen();
        gen.setDoc(xml.getBytes());
        gen.parse(false);
        VTDNav nav = gen.getNav();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        nav.writeIndex(os);

        //Get original XML
        ByteArrayOutputStream osOrig = new ByteArrayOutputStream();
        nav.dumpXML(osOrig);
       
        //Load VTD+XML into new Gen
        VTDGen gen2 = new VTDGen();
        VTDNav nav2 = gen2.loadIndex(os.toByteArray());

        //Attempt to get original XML
        ByteArrayOutputStream os2 = new ByteArrayOutputStream();
        nav2.dumpXML(os2);

    At this point osOrig and os2 should contain the same content, right?  However osOrig is correct, but os2 has characters tacked on to the front.  What am I doing wrong?

    Thanks

     
    • Mark Stuppy

      Mark Stuppy - 2008-08-18

      Also:  I'm using version 2.3

       
    • jimmy zhang

      jimmy zhang - 2008-08-18

      hmm.. it may be a bug, let me investigate and get back..

       
    • jimmy zhang

      jimmy zhang - 2008-08-22

      It is a bug and the fix (java version) has been checked in ...

       
    • Rahul Gupta

      Rahul Gupta - 2008-08-30

      Will we get a new version?
      Sorry, but I 'm new to this forum.

      I see the same issue in v2.4

       
      • jimmy zhang

        jimmy zhang - 2008-08-30

        This issue has been fixed you just have to go to VTD-XML CVS repository to check out the latest update...
        please post directly to vtd-xml-users mailing list if you need further instruction...

         

Log in to post a comment.