List of usage examples for org.w3c.dom Text insertData
public void insertData(int offset, String arg) throws DOMException;
From source file:Main.java
public static void editTextbyInsertionandReplacement(Document doc) { Element root = doc.getDocumentElement(); Element place = (Element) root.getFirstChild(); Text name = (Text) place.getFirstChild().getFirstChild(); Text directions = (Text) place.getLastChild().getFirstChild(); // Inserting the word "black" // name.insertData(offset," black"); name.insertData(3, " black"); // Replace "left" with "right" //directions.replaceData(offset,count,"right"); directions.replaceData(3, 3, "right"); }
From source file:DOMEdit.java
public static void editTextbyInsertionandReplacement(Document doc) { Element root = doc.getDocumentElement(); Element place = (Element) root.getFirstChild(); Text name = (Text) place.getFirstChild().getFirstChild(); Text directions = (Text) place.getLastChild().getFirstChild(); // Inserting the word "black" // name.insertData(offset," black"); name.insertData(3, " black"); // Replace "left" with "right" //directions.replaceData(offset,count,"right"); directions.replaceData(3, 3, "right"); }/* ww w. j a va2 s . c om*/