BeanIO 2.0.4

org.beanio.internal.parser.format.xml
Class XmlNodeUtil

java.lang.Object
  extended by org.beanio.internal.parser.format.xml.XmlNodeUtil

public class XmlNodeUtil
extends Object

Utility class for working with a document object model and an XmlNode.

Since:
2.0
Author:
Kevin Seim

Method Summary
static Element findChild(Node parent, XmlNode target, int offset)
          Finds the Nth matching child of a DOM element.
static Element findSibling(Element sibling, XmlNode target)
          Returns a sibling element that matches a given definition, or null if no match is found.
static String getAttribute(Element element, XmlNode definition)
          Returns the value of an attribute for an element.
static String getText(Node node)
          Returns the child text from a DOM node.
static boolean isNil(Element element)
          Tests if an element is nil.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNil

public static boolean isNil(Element element)
Tests if an element is nil.

Parameters:
element - the element to test
Returns:
true if the element is nil

getAttribute

public static String getAttribute(Element element,
                                  XmlNode definition)
Returns the value of an attribute for an element.

Parameters:
element - the element to check
definition - the definition of the attribute to retrieve from the element
Returns:
the defined attribute value, or null if the attribute was not found on the element

getText

public static String getText(Node node)
Returns the child text from a DOM node.

Parameters:
node - the node to parse
Returns:
the node text, or null if the node did not contain any text

findSibling

public static Element findSibling(Element sibling,
                                  XmlNode target)
Returns a sibling element that matches a given definition, or null if no match is found.

Parameters:
sibling - the sibling DOM element to begin the search
target - the node to search for
Returns:
the matching element, or null if not found

findChild

public static Element findChild(Node parent,
                                XmlNode target,
                                int offset)
Finds the Nth matching child of a DOM element.

Parameters:
parent - the parent DOM node
target - the node to search for
offset - the occurrence of the matching node
Returns:
the matching element, or null if no match is found

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim