| Author |
Need to modify xml using dom4j
|
Ranveer K Kumar
Ranch Hand
Joined: Sep 13, 2009
Posts: 64
|
|
Hi all,
I am new in dom4j and xml parsing. I need to modify the xml file. But I have no idea . I am trying to do but not succeed. Please help....
I have no idea so please help if i have done mistakes in core..but my goals is to modify the xml element..
following is code which i tried..
xml file...
I want to change above <desc> element with some other value.
I am trying to modify this file with some new value of <desc> by following code..
java file
after executing the above java file I am getting the following xml... but xml is not right...
thanks
with regards
Ranveer
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
I don't know what the "asXML" method does in dom4j, and I don't feel like hunting down its documentation on the web. So I'm just going to guess that you should be using some other method there. Like the getRootElement method for example. You didn't say why you wanted to do this or what the output should have been, so guessing is the only way forward.
|
 |
Ranveer K Kumar
Ranch Hand
Joined: Sep 13, 2009
Posts: 64
|
|
Paul Clapham wrote:I don't know what the "asXML" method does in dom4j, and I don't feel like hunting down its documentation on the web. So I'm just going to guess that you should be using some other method there. Like the getRootElement method for example. You didn't say why you wanted to do this or what the output should have been, so guessing is the only way forward.
Hi Paul,
thanks for reply.
actually I was getting follwoing extra line in output.xml file. asXML is simple parsing text to xml in dom4j. I am now able to modify the element in xml..
by following code (instead of asXML, because asXML method is adding "<?xml version="1.0" encoding="UTF-8"?>" line )
but still getting problem.
I am searching the element (by loop) when find, first remove that element and again adding the modified element on there. after that writing that xml again.
I looking forward to do same with XPath instead of loop. Because in my condition we know the element path.
please help..
|
 |
 |
|
|
subject: Need to modify xml using dom4j
|
|
|