fr.ensta.xml
Class XmlReader

java.lang.Object
  extended byfr.ensta.xml.XmlReader

public class XmlReader
extends java.lang.Object

A simple class for reading a xml hierarchy given by a xml file and displaying it.

This class is based on the Java XML tutorial, which can be found under http://java.sun.com/xml/jaxp/learning/tutorial/index.html

Created on 08.03.2005

Version:
1.0
Author:
Thomas Bretgeld

Constructor Summary
XmlReader()
           
 
Method Summary
static void print(org.w3c.dom.Node node)
          A recursive function to print a xml tree in Preorder Notation.
static void print(org.w3c.dom.Node node, int level)
          A recursive function to print a xml tree in Preorder Notation.
static void printIntelligent(org.w3c.dom.Node node)
          A recursive function to print a xml tree in an intelligent way in Preorder Notation.
static void printIntelligent(org.w3c.dom.Node node, int level)
          A recursive function to print a xml tree in Preorder Notation.
static org.w3c.dom.Node readXmlFile(java.lang.String filename)
          This function reads an xml file and return the root node of the xml tree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlReader

public XmlReader()
Method Detail

readXmlFile

public static org.w3c.dom.Node readXmlFile(java.lang.String filename)

This function reads an xml file and return the root node of the xml tree.

Parameters:
filename - The name and path of the xml configuration file
See Also:
Java XML Tutorial

print

public static void print(org.w3c.dom.Node node)
A recursive function to print a xml tree in Preorder Notation.

Attention! This function only prints Text, Comment and Element Nodes! Other node types will be ignored!

Parameters:
node - the node in the tree from where to start. This is usually the root node.
See Also:
Java XML Tutorial

print

public static void print(org.w3c.dom.Node node,
                         int level)
A recursive function to print a xml tree in Preorder Notation. This function shouldn't be called directly.

Attention! This function only prints Text, Comment and Element Nodes! Other node types will be ignored!

Parameters:
node - actual node to be processed
level - the level of this node which will result in apropriate spacing in front of the printed string.
See Also:
Java XML Tutorial

printIntelligent

public static void printIntelligent(org.w3c.dom.Node node)
A recursive function to print a xml tree in an intelligent way in Preorder Notation.

Attention! This function only prints Text, Comment and Element Nodes! Other node types will be ignored!

Parameters:
node - the node in the tree from where to start. This is usually the root node.
See Also:
Java XML Tutorial

printIntelligent

public static void printIntelligent(org.w3c.dom.Node node,
                                    int level)
A recursive function to print a xml tree in Preorder Notation. This function shouldn't be called directly.

Attention! This function only prints Text, Comment and Element Nodes! Other node types will be ignored!

Parameters:
node - actual node to be processed
level - the level of this node which will result in apropriate spacing in front of the printed string.
See Also:
Java XML Tutorial