1 | document = parser.readStream(in); |
2 | root = document.getDocumentElement(); |
3 | System.out.println("Node name: " + root.getNodeName()); |
4 | publications = root.getElementsByTagName("publication"); |
5 | publication = (Element) publications.item(0); |
6 | System.out.println("Node name: "+publication.getNodeName()); |
7 | title = (Element) (publication.getElementsByTagName("title")).item(0); |
8 | System.out.println("Node name: " + title.getNodeName()); |
9 | |
10 | titleText = (Text) title.getFirstChild(); |
11 | System.out.println("Title: " + titleText.getData()); |
12 | |
13 | titleText.setData("Something More Interesting"); |
14 | System.out.println("Title: " + titleText.getData()); |
15 | |
16 | pw = new PrintWriter(new BufferedWriter (new FileWriter(args[0]))); |
17 | |
18 | document.printWithFormat(pw); |