0

I am fairly new to XOM. I want to insert a child(<stmt> </stmt>) into the node <mast_stmt></mast_stmt> at a specified index but what I get in the XML document at the correct position is &lt;stmt &gt; &lt;/stmt&gt; and this is what I am really after <stmt> </stmt>

Here is my code section that handles insertion:

 parentNode1.insertChild("<stmt></stmt>", index + 1);
har07
  • 88,338
  • 12
  • 84
  • 137
Mover
  • 169
  • 12

1 Answers1

2

You are supposed to create new Element instance and pass it as parameter of insertChild() :

Element newElement = new Element("stmt");
parentNode1.insertChild(newElement, index + 1);
har07
  • 88,338
  • 12
  • 84
  • 137