The Encog Project

org.encog.util
Class XMLUtil

java.lang.Object
  extended by org.encog.util.XMLUtil

public final class XMLUtil
extends java.lang.Object

Simple XML utilities for parsing.

Author:
jheaton

Method Summary
static void addAttribute(org.w3c.dom.Node e, java.lang.String name, java.lang.String value)
          Add the specified attribute.
static org.w3c.dom.Node createProperty(org.w3c.dom.Document doc, java.lang.String name, java.lang.String value)
          Create a property element.
static org.w3c.dom.Element findElement(org.w3c.dom.Element e, java.lang.String find)
          Find a child element.
static int findElementAsInt(org.w3c.dom.Element e, java.lang.String find, int def)
          Find an element, return as an int.
static long findElementAsLong(org.w3c.dom.Element e, java.lang.String find, long def)
          Find an element, return as a long.
static java.lang.String findElementAsString(org.w3c.dom.Element e, java.lang.String find)
          Find an element, return as a string.
static java.lang.String getElementValue(org.w3c.dom.Element e)
          Get the specified element's text value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addAttribute

public static void addAttribute(org.w3c.dom.Node e,
                                java.lang.String name,
                                java.lang.String value)
Add the specified attribute.

Parameters:
e - The node to add the attribute to.
name - The name of the attribute.
value - The value of the attribute.

createProperty

public static org.w3c.dom.Node createProperty(org.w3c.dom.Document doc,
                                              java.lang.String name,
                                              java.lang.String value)
Create a property element. Do not append it though!

Parameters:
doc - The document to use.
name - The name of the property.
value - The value to add to the property.
Returns:
The newly created property.

findElement

public static org.w3c.dom.Element findElement(org.w3c.dom.Element e,
                                              java.lang.String find)
Find a child element.

Parameters:
e - The element to search.
find - The name to search for.
Returns:
The element found, or null if not found.

findElementAsInt

public static int findElementAsInt(org.w3c.dom.Element e,
                                   java.lang.String find,
                                   int def)
Find an element, return as an int.

Parameters:
e - The element that searches.
find - What we are searching for.
def - The default value, if we fail to find it.
Returns:
The value found, default value otherwise.

findElementAsLong

public static long findElementAsLong(org.w3c.dom.Element e,
                                     java.lang.String find,
                                     long def)
Find an element, return as a long.

Parameters:
e - The element that searches.
find - What we are searching for.
def - The default value, if we fail to find it.
Returns:
The value found, default value otherwise.

findElementAsString

public static java.lang.String findElementAsString(org.w3c.dom.Element e,
                                                   java.lang.String find)
Find an element, return as a string.

Parameters:
e - The element that searches.
find - What we are searching for.
Returns:
The value found, default value otherwise.

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Element e)
Get the specified element's text value.

Parameters:
e - The element.
Returns:
The text value of the specified element.

The Encog Project