I Have XML with this structure:
<ms:tech ID="TM_002">
<ms:wrap MDTYPE="NISOIMG" MIMETYPE="text/xml">
<ms:xmlData>
<ml:ml>
<mx:BasicInformation>
<mx:ObjectIdentifier>
<mx:objectIdentifierType>Value</mix:objectIdentifierType>
</mx:ObjectIdentifier>
**-----HERE AT THIS POSITION INSERT NEW XML TAG------**
<mx:byteOrder>Value2</mx:byteOrder>
<mx:Compression>
<mx:compressionScheme>Uncompressed</mx:compressionScheme>
</mx:Compression>
</mx:BasicInformation>
</ml:ml>
<ms:xmlData>
</ms:wrap>
</ms:tech>
I want to insert new XML tag at specific position in XML tree. My code so far looks like this:
String xp = "//ms:tech[@ID='TM_002']/ms:wrap/ms:xmlData/ml:ml/mx:BasicInformation";
List<Node> list = amdDocument.selectNodes(xp);
Node element = list.get(0);
By this I got the tag, and in this tag I want insert new one after . Im using dom4j. How can I do this? Thanks.