Package de.timroes.axmlrpc
Class XMLUtil
- java.lang.Object
-
- de.timroes.axmlrpc.XMLUtil
-
public class XMLUtil extends java.lang.Object
This class provides some utility methods for the use with the Java DOM parser.- Author:
- Tim Roes
-
-
Constructor Summary
Constructors Constructor Description XMLUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.Element
getOnlyChildElement(org.w3c.dom.NodeList list)
Returns the only child element in a given NodeList.static java.lang.String
getOnlyTextContent(org.w3c.dom.NodeList list)
Returns the text node from a given NodeList.static boolean
hasChildElement(org.w3c.dom.NodeList list)
Checks if the givenNodeList
contains a child element.static XmlElement
makeXmlTag(java.lang.String type, java.lang.String content)
Creates an xml tag with a given type and content.
-
-
-
Method Detail
-
getOnlyChildElement
public static org.w3c.dom.Element getOnlyChildElement(org.w3c.dom.NodeList list) throws XMLRPCException
Returns the only child element in a given NodeList. Will throw an error if there is more then one child element or any other child that is not an element or an empty text string (whitespace are normal).- Parameters:
list
- A NodeList of children nodes.- Returns:
- The only child element in the given node list.
- Throws:
XMLRPCException
- Will be thrown if there is more then one child element except empty text nodes.
-
getOnlyTextContent
public static java.lang.String getOnlyTextContent(org.w3c.dom.NodeList list) throws XMLRPCException
Returns the text node from a given NodeList. If the list contains more then just text nodes, an exception will be thrown.- Parameters:
list
- The given list of nodes.- Returns:
- The text of the given node list.
- Throws:
XMLRPCException
- Will be thrown if there is more than just one text node within the list.
-
hasChildElement
public static boolean hasChildElement(org.w3c.dom.NodeList list)
Checks if the givenNodeList
contains a child element.- Parameters:
list
- TheNodeList
to check.- Returns:
- Whether the
NodeList
contains children.
-
makeXmlTag
public static XmlElement makeXmlTag(java.lang.String type, java.lang.String content)
Creates an xml tag with a given type and content.- Parameters:
type
- The type of the xml tag. What will be filled in the <..>.content
- The content of the tag.- Returns:
- The xml tag with its content as a string.
-
-