org.apache.hadoop.vaidya.util
Class XMLUtils

java.lang.Object
  extended by org.apache.hadoop.vaidya.util.XMLUtils

public class XMLUtils
extends Object

Sample Utility class to work with DOM document


Constructor Summary
XMLUtils()
           
 
Method Summary
static int countByTagName(String tag, Document document)
          Count Elements in Document by Tag Name
static String getElementValue(String elementName, Element element)
           
static Document parse(InputStream fs)
          Parse the XML file and create Document
static void printDOM(Node node)
          Prints the specified node, then prints all of its children.
static void writeXmlToFile(String filename, Document document)
          This method writes a DOM document to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

printDOM

public static void printDOM(Node node)
Prints the specified node, then prints all of its children.


getElementValue

public static String getElementValue(String elementName,
                                     Element element)
                              throws Exception
Throws:
Exception

parse

public static Document parse(InputStream fs)
Parse the XML file and create Document

Returns:
Document

writeXmlToFile

public static void writeXmlToFile(String filename,
                                  Document document)
This method writes a DOM document to a file

Parameters:
filename -
document -

countByTagName

public static int countByTagName(String tag,
                                 Document document)
Count Elements in Document by Tag Name

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


Copyright © 2009 The Apache Software Foundation