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