KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Given the following XML file: <?xml version="1.0" encoding="UTF-8"?> <process name="TestSVG2" xmlns="http://www.example.org" targetNamespace="http://www.example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <sequence> <receive name="Receive1" createInstance="yes"/> <assign name="Assign1"/> <invoke name="Invoke1"/> <assign name="Assign2"/> <reply name="Reply1"/> </sequence> </process> I want to add a new element inside the <sequence></sequence> after a certain pre-existing element . For example if I want to add the node after "Assign1" , the new XML should like this: <sequence> <receive name="Receive1" createInstance="yes"/> <assign name="Assign1"/> <newtype name="NewNode"/> <invoke name="Invoke1"/> <assign name="Assign2"/> <reply name="Reply1"/> </sequence> I have to do this by using Java DOM, in a function. The function signature should like this: public void addActionDom(String name, String stepType, String stepName) Where: name is the pre-existing element, after which the insertion will be made; stepType is the inserted element type; stepName is the name attribute of the newly inserted element. Currently I am lacking experience with JDOM, or any other Java XML library. Can you please give a sample code, or point me to a tutorial where an insertion after a certain element is made. This is the code I have until now: public void addActionDom(String name, String stepType, String stepName) { File xmlFile = new File(path + "/resources/" + BPELFilename); DocumentBui
Tags (comma-separated)
Save Edits
Cancel