public class MXml extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MXml.ElementIterator |
static class |
MXml.NodeIterator |
static interface |
MXml.ValueListener |
| Constructor and Description |
|---|
MXml() |
| Modifier and Type | Method and Description |
|---|---|
static void |
carveOut(Element element)
Remove the element from his parent but append the children
instead if it into the parent node - on the same position.
|
static Document |
createDocument()
Create and return a empty xml document.
|
static String |
decode(String _in)
Decodes a string with encoded characters to a java string.
|
static String |
dump(Node element)
Prints information - most technical - of the xml element and its childs and returns it as string.
|
static void |
dump(PrintStream o,
Node element)
Prints information - most technical - of the xml element and its childs to the stream.
|
static void |
dump(PrintStream out,
NodeList nodes) |
static void |
dump(PrintStream o,
Node node,
String level) |
static String |
encode(String _in)
Encode the default problematic characters in a string to store it in a xml value.
|
static Element |
getElementByPath(Element root,
String path)
Returns the first found element by path.
|
static MXml.ElementIterator |
getLocalElementIterator(Element root)
Returns an iterator of all elements in the given root element on the first level only.
|
static MXml.ElementIterator |
getLocalElementIterator(Element root,
String name)
Returns an iterator of elements with this name in the given root element on the first level only.
|
static NodeList |
getLocalElements(Element root)
Returns a list of all elements in the given root element on the first level only.
|
static NodeList |
getLocalElements(Element root,
String name)
Returns a list of elements with this name in the given root element on the first level only.
|
static String |
getPathAsString(Node in)
Returns the path to the node as string representation, separated with slashes.
|
static String |
getValue(Element root,
boolean inner)
Returns the text value of a node.
|
static String |
getValue(Element root,
MXml.ValueListener listener)
Returns the text value of a node.
|
static String |
innerXml(Node node)
Returns the inner XML Structure as string with all tag definitions.
|
static String |
innerXml(Node node,
boolean instructions)
Returns the inner XML Structure as string with all tag definitions.
|
static Document |
loadXml(InputStream is)
Create a XML Document from a stream resource.
|
static Document |
loadXml(Reader file) |
static Document |
loadXml(String xml)
Create a XML Document from a string.
|
static Document |
loadXml(String xml,
String charset)
Create a XML Document from a string.
|
static String |
normalizeName(String key)
Normalize the name of attributes or node names.
|
static MXml.NodeIterator |
queryXPath(Node root,
String query)
Execute an XPATH query for a list of nodes.
|
static MXml.ElementIterator |
queryXPathElements(Node root,
String query)
Execute an XPATH query for a list of elements.
|
static String |
removeHtmlTags(String txt) |
static String |
removeTags(String txt) |
static void |
saveXml(Node e,
OutputStream out)
Write the element into the stream.
|
static void |
saveXml(Node e,
Writer out,
boolean intend) |
static String |
toString(Node e,
boolean intend) |
static void |
trim(Element element)
Remove white spaces in the text nodes.
|
static String |
unicodeEncode(String _in)
Encodes the amp and all characters greater then 255 to unicode representation with amp and hash signs.
|
public static String getValue(Element root, boolean inner)
root - The element where you need the text value frominner - If true all inner elements are parsed and the text appendedpublic static String getValue(Element root, MXml.ValueListener listener)
root - listener - public static NodeList getLocalElements(Element root, String name)
root - name - public static NodeList getLocalElements(Element root)
root - public static MXml.ElementIterator getLocalElementIterator(Element root, String name)
root - name - public static MXml.ElementIterator getLocalElementIterator(Element root)
root - public static Element getElementByPath(Element root, String path)
root - path - public static String getPathAsString(Node in)
in - public static Document loadXml(String xml, String charset) throws ParserConfigurationException, UnsupportedEncodingException, SAXException, IOException
xml - charset - ParserConfigurationExceptionUnsupportedEncodingExceptionSAXExceptionIOExceptionpublic static Document loadXml(String xml) throws ParserConfigurationException, SAXException, IOException
xml - ParserConfigurationExceptionSAXExceptionIOExceptionpublic static Document loadXml(InputStream is) throws ParserConfigurationException, SAXException, IOException
is - ParserConfigurationExceptionSAXExceptionIOExceptionpublic static Document loadXml(Reader file) throws ParserConfigurationException, SAXException, IOException
public static void saveXml(Node e, OutputStream out) throws Exception
e - out - Exceptionpublic static void saveXml(Node e, Writer out, boolean intend) throws Exception
Exceptionpublic static Document createDocument() throws Exception
Exceptionpublic static String encode(String _in)
_in - public static String unicodeEncode(String _in)
_in - public static String decode(String _in)
public static String dump(Node element)
element - public static void dump(PrintStream o, Node element)
o - element - public static void dump(PrintStream o, Node node, String level)
public static void dump(PrintStream out, NodeList nodes)
public static String innerXml(Node node)
node - public static String innerXml(Node node, boolean instructions)
node - instructions - set to false to ignore processing instructions (on the first level)public static MXml.NodeIterator queryXPath(Node root, String query) throws XPathExpressionException
root - query - XPathExpressionExceptionpublic static MXml.ElementIterator queryXPathElements(Node root, String query) throws XPathExpressionException
root - query - XPathExpressionExceptionpublic static void trim(Element element)
element - public static void carveOut(Element element)
element - public static String normalizeName(String key)
key - Copyright © 2014. All rights reserved.