dom4j-java- how to change the value of an attribute

Cactlootaws

New Member
In a Java program, i am processing an xml using dom4j.Now, I want to update an attribute of an element.This is the code I am using to obtain that element--\[code\] SAXReader reader = new SAXReader(); doc = reader.read(new StringReader(xmlinput)); Element root = doc.getRootElement(); for ( Iterator i = root.elementIterator( "cloudwhile" ); i.hasNext(); ) { Element foo = (Element) i.next();\[/code\]Now, I want to update the value of an attribute of element 'foo'--For this I am trying to use the following code--\[code\] foo.setAttributeValue("indexstart", (String) newstart );\[/code\]However the above method is deprecated... how do I update the attribute now? Also, I want to take the string representation of the modified xml, immediately after updating the attribute of element 'foo'- how do I do that?
 
Back
Top