public void LocatingUsingSibling(Document doc,String newname,String newemail) {
Element root = doc.getDocumentElement();
Element person = (Element)root.getFirstChild();
while(person != null) {
Element name = (Element)person.getFirstChild();
Text nametext = (Text)name.getFirstChild();
String oldname = nametext.getData();
if(oldname.equals(newname)) {
Element email = (Element)name.getNextSibling();
Text emailtext = (Text)email.getFirstChild();
emailtext.setData(newemail);
}
person = (Element)person.getNextSibling();
}
}
|