|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.uoa.di.madgik.commons.utils.XMLUtils
public class XMLUtils
Utility class to parse and traverse an XML DOM tree
Constructor Summary | |
---|---|
XMLUtils()
|
Method Summary | |
---|---|
static java.lang.Boolean |
AttributeExists(org.w3c.dom.Element node,
java.lang.String attributeName)
Checks if the provided attribute exists in the supplied node |
static org.w3c.dom.Document |
Deserialize(java.io.File XML)
|
static org.w3c.dom.Document |
Deserialize(java.lang.String XML)
Parses the provided XML string |
static java.lang.String |
DoReplaceSpecialCharachters(java.lang.String XML)
Replaces special characters with xml valid escape sequences. |
static java.lang.String |
GetAttribute(org.w3c.dom.Element node,
java.lang.String attributeName)
Retrieves an attribute's value |
static java.lang.String[] |
GetAttributes(org.w3c.dom.Element node,
boolean CollapseNamespase)
|
static java.lang.String |
GetChildCDataText(org.w3c.dom.Node Parent)
|
static java.util.List<org.w3c.dom.Element> |
GetChildElementsWithName(org.w3c.dom.Node Parent,
java.lang.String name)
Retrieves all child elements of the provided node that have the provided name |
static java.util.List<org.w3c.dom.Element> |
GetChildElementsWithNameAndNamespace(org.w3c.dom.Node Parent,
java.lang.String name,
java.lang.String ns)
|
static org.w3c.dom.Element |
GetChildElementWithName(org.w3c.dom.Node Parent,
java.lang.String name)
Retrieves a single child element of the provided node that has the provided name. |
static org.w3c.dom.Element |
GetChildElementWithNameAndNamespace(org.w3c.dom.Node Parent,
java.lang.String name,
java.lang.String ns)
|
static java.lang.String |
GetChildText(org.w3c.dom.Node Parent)
Retrieves the text payload of the first available Text node that is a member of the provided node children |
static java.lang.String |
GetChildTextOrFirstNonEmptyChildElementAsText(org.w3c.dom.Node Parent)
|
static java.lang.Object |
Query(org.w3c.dom.Document doc,
java.lang.String query,
javax.xml.namespace.QName type)
|
static java.lang.String |
Serialize(org.w3c.dom.Node node)
|
static java.lang.String |
Serialize(org.w3c.dom.Node node,
boolean omitDeclaration)
|
static void |
Serialize(java.lang.String FileName,
java.lang.String XML)
|
static java.lang.String |
SerializeChild(org.w3c.dom.Element parent)
|
static java.lang.String |
Transform(java.lang.String Source,
java.lang.String xslt)
|
static java.lang.String |
UndoReplaceSpecialCharachters(java.lang.String XML)
Replaces valid xml escape sequences to their original form |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLUtils()
Method Detail |
---|
public static void Serialize(java.lang.String FileName, java.lang.String XML) throws java.lang.Exception
java.lang.Exception
public static java.lang.String Serialize(org.w3c.dom.Node node, boolean omitDeclaration) throws java.lang.Exception
java.lang.Exception
public static java.lang.String Serialize(org.w3c.dom.Node node) throws java.lang.Exception
java.lang.Exception
public static org.w3c.dom.Document Deserialize(java.lang.String XML) throws java.lang.Exception
XML
- the xml to parse
Document
constructed
java.lang.Exception
- the deserialization could not be performedpublic static org.w3c.dom.Document Deserialize(java.io.File XML) throws java.lang.Exception
java.lang.Exception
public static java.lang.Boolean AttributeExists(org.w3c.dom.Element node, java.lang.String attributeName) throws java.lang.Exception
node
- the Node that should hold the attributeattributeName
- the name of the attribute to check for
java.lang.Exception
- The operation could not be performedpublic static java.lang.String GetAttribute(org.w3c.dom.Element node, java.lang.String attributeName) throws java.lang.Exception
node
- The node the attribute should exist inattributeName
- the name of the attribute
java.lang.Exception
- The attribute does not existpublic static java.lang.String[] GetAttributes(org.w3c.dom.Element node, boolean CollapseNamespase) throws java.lang.Exception
java.lang.Exception
public static java.lang.String SerializeChild(org.w3c.dom.Element parent) throws java.lang.Exception
java.lang.Exception
public static org.w3c.dom.Element GetChildElementWithName(org.w3c.dom.Node Parent, java.lang.String name) throws java.lang.Exception
Parent
- the node to check its childrenname
- the name of the child node to retrieve
java.lang.Exception
- the Operation could not be performedpublic static org.w3c.dom.Element GetChildElementWithNameAndNamespace(org.w3c.dom.Node Parent, java.lang.String name, java.lang.String ns) throws java.lang.Exception
java.lang.Exception
public static java.util.List<org.w3c.dom.Element> GetChildElementsWithName(org.w3c.dom.Node Parent, java.lang.String name) throws java.lang.Exception
Parent
- the node to check its childrenname
- the name of the child node to retrieve
java.lang.Exception
- the Operation could not be performedpublic static java.util.List<org.w3c.dom.Element> GetChildElementsWithNameAndNamespace(org.w3c.dom.Node Parent, java.lang.String name, java.lang.String ns) throws java.lang.Exception
java.lang.Exception
public static java.lang.String GetChildTextOrFirstNonEmptyChildElementAsText(org.w3c.dom.Node Parent) throws java.lang.Exception
java.lang.Exception
public static java.lang.String GetChildCDataText(org.w3c.dom.Node Parent) throws java.lang.Exception
java.lang.Exception
public static java.lang.String GetChildText(org.w3c.dom.Node Parent) throws java.lang.Exception
Parent
- The node whose child text node's payload should be retrieved
java.lang.Exception
- the Operation could not be performedpublic static java.lang.Object Query(org.w3c.dom.Document doc, java.lang.String query, javax.xml.namespace.QName type) throws java.lang.Exception
java.lang.Exception
public static java.lang.String Transform(java.lang.String Source, java.lang.String xslt) throws java.lang.Exception
java.lang.Exception
public static java.lang.String DoReplaceSpecialCharachters(java.lang.String XML)
XML
- The xml to escape
public static java.lang.String UndoReplaceSpecialCharachters(java.lang.String XML)
XML
- the escaped xml
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |