document = parser.readStream(in); |
root = document.getDocumentElement(); |
System.out.println("Node name: " + root.getNodeName()); |
publications = root.getElementsByTagName("publication"); |
publication = (Element) publications.item(0); |
System.out.println("Node name: "+publication.getNodeName()); |
title = (Element) (publication.getElementsByTagName("title")).item(0); |
System.out.println("Node name: " + title.getNodeName()); |
titleText = (Text) title.getFirstChild(); |
System.out.println("Title: " + titleText.getData()); |
titleText.setData("Something More Interesting"); |
System.out.println("Title: " + titleText.getData()); |
pw = new PrintWriter(new BufferedWriter (new FileWriter(args[0]))); |
document.printWithFormat(pw); |