Java DOM edit: Edit Text by Insertion and Replacement
public void edit3(Document doc) {
int count;
int offset;
Element root = doc.getDocumentElement();
Element place = (Element)root.getFirstChild();
Text name = (Text)place.getFirstChild().getFirstChild();
Text directions = (Text)place.getLastChild().getFirstChild();
offset = 7;
name.insertData(offset," black");
offset = 5;
count = 4;
directions.replaceData(offset,count,"right");
}
Related examples in the same category