| java.lang.Object com.nabhinc.util.XMLUtil
XMLUtil | abstract public class XMLUtil (Code) | | Miscelleneous XML utility methods that help extract text and elements from a
DOM tree.
author: Padmanabh Dabke (c) 2001,2003 Nabh Information Systems, Inc. All author: Rights Reserved. |
Method Summary | |
public static String | getChildCharacterData(Element parentEl) Concat all the text and cdata node children of this elem and return the
resulting text.
Parameters: parentEl - the element whose cdata/text node values are to be combined. | public static String | getElementText(Element n) Returns the text body of the element. | public static Element | getFirstSubElement(Element el) Returns first direct child that is an XML element. | public static Element | getRootElementFromString(String xmlSpec) Parses given XML string and returns the document root element. | public static Element | getRootElementFromURL(String urlStr) Reads XML data from the given URL, parses it, and returns the document
root element. | public static Element | getSubElement(Element el, String tag) Returns first direct child element with the given tag. | public static Element | getSubElementRecursive(Element el, String tag) Returns first direct child element with the given tag. | public static String | getSubElementText(Element el, String tag) Returns the text body of the first subelement with given tag. | public static String | getSubElementText(Element el, String tag, String defaul) Returns the text body of the first subelement with given tag. | public static int | getSubElementTextAsInt(Element el, String tag) Uses getSubElementText to get the value of a subnode, converts it to int
and returns it. | public static String | getSubElementTextGlobal(Element el, String tag) Returns the text body of the first subelement with given tag with any XML
scope. | public static String | getSubElementTextRecursive(Element el, String tag) Returns the text body of the first subelement with given tag. | public static String | getSubElementTextRecursive(Element el, String tag, String defaul) Returns the text body of the first subelement with given tag. | public static Element[] | getSubElements(Element el, String tag) Returns all direct child element with the given tag. | public static void | writeElement(Object elem, String tag, java.io.Writer w) Writes an XML element with the given tag. | public static void | writeElement(String indent, String tag, String value, Writer w) | public static void | writeElementEnd(String indent, String tag, Writer w) | public static void | writeElementStart(String indent, String tag, Writer w) | public static void | writeEmptyElement(String indent, String tag, Writer w) |
LINE_FEED | public static String LINE_FEED(Code) | | Line feed string. Useful in writing multiline text files.
|
getChildCharacterData | public static String getChildCharacterData(Element parentEl)(Code) | | Concat all the text and cdata node children of this elem and return the
resulting text.
Parameters: parentEl - the element whose cdata/text node values are to be combined. the concatanated string. |
getElementText | public static String getElementText(Element n)(Code) | | Returns the text body of the element. Returns
null if there is no body.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getFirstSubElement | public static Element getFirstSubElement(Element el)(Code) | | Returns first direct child that is an XML element.
First child that is an XML element Parameters: el - Parent element |
getSubElement | public static Element getSubElement(Element el, String tag)(Code) | | Returns first direct child element with the given tag.
Firstirect child with the given tag or null Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getSubElementRecursive | public static Element getSubElementRecursive(Element el, String tag)(Code) | | Returns first direct child element with the given tag.
Firstirect child with the given tag or null Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getSubElementText | public static String getSubElementText(Element el, String tag)(Code) | | Returns the text body of the first subelement with given tag. Returns
null if it does not find a node with the given tag.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getSubElementText | public static String getSubElementText(Element el, String tag, String defaul)(Code) | | Returns the text body of the first subelement with given tag. Returns
supplied default if it does not find a node with the given tag.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for defaultDefault string to return in case an element with the specifiedtag does not exist. |
getSubElementTextAsInt | public static int getSubElementTextAsInt(Element el, String tag)(Code) | | Uses getSubElementText to get the value of a subnode, converts it to int
and returns it.
int value stored in the subelement text Parameters: el - Parent element Parameters: tag - Tag to look for |
getSubElementTextGlobal | public static String getSubElementTextGlobal(Element el, String tag)(Code) | | Returns the text body of the first subelement with given tag with any XML
scope.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getSubElementTextRecursive | public static String getSubElementTextRecursive(Element el, String tag)(Code) | | Returns the text body of the first subelement with given tag. Returns
null if it does not find a node with the given tag.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
getSubElementTextRecursive | public static String getSubElementTextRecursive(Element el, String tag, String defaul)(Code) | | Returns the text body of the first subelement with given tag. Returns
supplied default if it does not find a node with the given tag.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for defaultDefault string to return in case an element with the specifiedtag does not exist. |
getSubElements | public static Element[] getSubElements(Element el, String tag)(Code) | | Returns all direct child element with the given tag.
Direct children with the given tag Parameters: el - Parent element Parameters: tag - Subelement tag to look for |
|
|