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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -