name.alessiosaltarin.utils
Class DOMUtils

java.lang.Object
  extended by name.alessiosaltarin.utils.DOMUtils

public class DOMUtils
extends java.lang.Object

This class provides basic operations with XML files using DOM.


Constructor Summary
DOMUtils()
           
 
Method Summary
static int countByTagName(java.lang.String tag, org.w3c.dom.Document document)
          Count Elements in Document by Tag Name
static org.w3c.dom.Document parse(java.io.File xmlfile)
          Parse the XML file and create Document
static org.w3c.dom.Document parse(java.io.File xmlfile, boolean namespaceAware)
          Parse the XML file and create Document
static void printNode(org.w3c.dom.Node node)
          Provides a representation of XML to stdout.
static void writeDomToFile(java.lang.String filename, org.w3c.dom.Document document)
          This method writes a DOM document to a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMUtils

public DOMUtils()
Method Detail

printNode

public static void printNode(org.w3c.dom.Node node)
Provides a representation of XML to stdout.

Parameters:
node - It can be a document, an element, an entity, CDATA, text.

parse

public static org.w3c.dom.Document parse(java.io.File xmlfile,
                                         boolean namespaceAware)
Parse the XML file and create Document

Parameters:
xmlfile - Path to XML file
namespaceAware - The parser must parse namespaces too
Returns:
Document XML DOM Document
See Also:
Document

parse

public static org.w3c.dom.Document parse(java.io.File xmlfile)
Parse the XML file and create Document

Parameters:
xmlfile - XML file to parse
Returns:
Document Parsed document

writeDomToFile

public static void writeDomToFile(java.lang.String filename,
                                  org.w3c.dom.Document document)
This method writes a DOM document to a file

Parameters:
filename -
document -

countByTagName

public static int countByTagName(java.lang.String tag,
                                 org.w3c.dom.Document document)
Count Elements in Document by Tag Name

Parameters:
tag -
document -
Returns:
number elements by Tag Name

Jurpe - Java Universal Role Playing Engine - http://jurpe.sourceforge.net