Basic HTML version of Foils prepared July 6 99

Foil 15 Document Object Model - Example

From Introduction to XML CPS714 Computational Science Information Track -- June 9 99. by Lukasz Beca


1
2 root = doc.getDocumentElement();
3 //print tag name
4 System.out.println(root.getTagName());
5 //get first child element of the root
6 docElem = (Node) root.getFirstChild();
7 //print tag name
8 System.out.println(docElem.getTagName());
9 //print element type
10 System.out.println(docElem.getNodeType());
11 //print node value
12 docElem1 = (Text) docElem.getFirstChild();
13 System.out.println(docElem1.getNodeValue());

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999