//A Document with Two Simple Text Nodes
/*
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE locations [
<!ELEMENT locations (place)*>
<!ELEMENT place (name | directions)*>
<!ELEMENT name (#PCDATA)>
<!ELEMENT directions (#PCDATA)>
]>
<locations>
<place>
<name>Fishing hole</name>
<directions>Turn left at bridge</directions>
</place>
</locations>
*/
public void edit(Document doc) {
Element root = doc.getDocumentElement();
Element place = (Element)root.getFirstChild();
Text name = (Text)place.getFirstChild().getFirstChild();
Text directions = (Text)place.getLastChild().getFirstChild();
name.setData("AAA");
directions.setData("BBB");
}
|