How to modify XML tag in Java? -
i have xml file tag following :
<sometag/>
i want modify tag following :
<sometag>somevalue</sometag>
initially tried delete element , create new element, doesnt work. know there method rename tag, tried following code, dont know how add value (somevalue) renamed element(sometag).
nodelist scpnodes=doc.getelementsbytagname("sometag"); (int = 0; < scpnodes.getlength(); i++) { element tobereplaced=(element) scpnodes.item(i); doc.renamenode(tobereplaced, tobereplaced.getnamespaceuri(),"sometag"); // how append value ? }
you have call
tobereplaced.settextcontext("somevalue");
and rid of
doc.renamenode(tobereplaced, tobereplaced.getnamespaceuri(),"sometag");
Comments
Post a Comment