Tuesday, 15 September 2015

vtd xml - VTD-XML creating an XML document -



vtd xml - VTD-XML creating an XML document -

i bit confused on how this, of docs / examples show how read , edit xml docs there doesn't seem clear way of creating xml scratch, rather not have ship programme dummy xml file in order edit one. ideas? thanks.

what instead hard-code empty document this:

byte[] emptydoc = "<?xml version='1.0' encoding='utf-8'?><root></root>".getbytes("utf-8");

and utilize create vtdgen , xmlmodifier, , start adding elements:

vtdgen vg = new vtdgen(); vg.setdoc(emptydoc); vg.parse(true); vtdnav vn = vg.getnav(); xmlmodifier xm = new xmlmodifier(vn); // cursor @ root, update root element name xm.updateelementname("employee"); xm.insertattribute(" id='6'"); xm.insertafterhead("<name>bob smith</name>"); vn = xm.outputandreparse(); // etc...

vtd-xml

No comments:

Post a Comment