com.openholdem.util
Class DOMUtil

java.lang.Object
  extended by com.openholdem.util.DOMUtil

public class DOMUtil
extends java.lang.Object

This class was taken from an O'Reilly site on DOM utilities. It contains a few helper methods to make extracting out XML text from DOM representations a little easier.

Version:
$Revision: 1.2 $
Author:
Chris Mattmann

Constructor Summary
DOMUtil()
           
 
Method Summary
static org.w3c.dom.Element getFirstElement(org.w3c.dom.Element element, java.lang.String name)
          Method returns the First occurence of Element 'name' in the DOM Node 'element'.
static java.lang.String getSimpleElementText(org.w3c.dom.Element node)
          This function is intended for use when you have merely text between an XML Element (i.e.
static java.lang.String getSimpleElementText(org.w3c.dom.Element node, java.lang.String name)
          This function is intended when you have a DOM element with no other DOM elements inside (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMUtil

public DOMUtil()
Method Detail

getFirstElement

public static org.w3c.dom.Element getFirstElement(org.w3c.dom.Element element,
                                                  java.lang.String name)
                                           throws java.lang.Exception

Method returns the First occurence of Element 'name' in the DOM Node 'element'.

Parameters:
element - The DOM Element node to traverse.
name - The XML name of the Element to return.
Returns:
Element "element" with Name "name"'s first occurence.
Throws:
java.lang.Exception

getSimpleElementText

public static java.lang.String getSimpleElementText(org.w3c.dom.Element node,
                                                    java.lang.String name)
                                             throws java.lang.Exception

This function is intended when you have a DOM element with no other DOM elements inside (i.e. here is text)

Parameters:
node - The DOM 'SimpleElement' as defined in the Function definition.
name - The name of the Text to retreive.
Returns:
the Text inbetween the simple element tags.
Throws:
java.lang.Exception

getSimpleElementText

public static java.lang.String getSimpleElementText(org.w3c.dom.Element node)

This function is intended for use when you have merely text between an XML Element (i.e. text here).

Parameters:
node - The DOM XML Tag, with text inbetween.
Returns:
String text inbetween the simple element tag.


Copyright © 2005-2007 Pagemewhen.com. All Rights Reserved.