public class MXml extends Object
MXml class.
| 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)
dump.
|
static void |
dump(PrintStream o,
Node node,
String level)
dump.
|
static String |
encode(String _in)
Encode the default problematic characters in a string to store it in a xml value.
|
static CDATASection |
findCDataSection(Element a)
findCDataSection.
|
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 |
getValue(Element root,
String path,
String def)
getValue.
|
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)
loadXml.
|
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)
removeHtmlTags.
|
static String |
removeTags(String txt)
removeTags.
|
static void |
saveXml(Node e,
OutputStream out)
Write the element into the stream.
|
static void |
saveXml(Node e,
Writer out,
boolean intend)
saveXml.
|
static String |
toString(Node e,
boolean intend)
toString.
|
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 - a Element object.listener - a MXml.ValueListener object.public static NodeList getLocalElements(Element root, String name)
public static NodeList getLocalElements(Element root)
root - a Element object.public static MXml.ElementIterator getLocalElementIterator(Element root, String name)
public static MXml.ElementIterator getLocalElementIterator(Element root)
root - a Element object.MXml.ElementIterator object.public static Element getElementByPath(Element root, String path)
public static String getPathAsString(Node in)
in - a Node object.public static Document loadXml(String xml, String charset) throws ParserConfigurationException, UnsupportedEncodingException, SAXException, IOException
xml - a String object.charset - a String object.Document object.ParserConfigurationException - if any.UnsupportedEncodingException - if any.SAXException - if any.IOException - if any.public static Document loadXml(String xml) throws ParserConfigurationException, SAXException, IOException
xml - a String object.Document object.ParserConfigurationException - if any.SAXException - if any.IOException - if any.public static Document loadXml(InputStream is) throws ParserConfigurationException, SAXException, IOException
is - a InputStream object.Document object.ParserConfigurationException - if any.SAXException - if any.IOException - if any.public static Document loadXml(Reader file) throws ParserConfigurationException, SAXException, IOException
loadXml.
file - a Reader object.Document object.ParserConfigurationException - if any.SAXException - if any.IOException - if any.public static void saveXml(Node e, OutputStream out) throws Exception
e - a Node object.out - a OutputStream object.Exception - if any.public static Document createDocument() throws Exception
public static String encode(String _in)
public static String unicodeEncode(String _in)
public static String decode(String _in)
public static String dump(Node element)
public static void dump(PrintStream o, Node element)
o - a PrintStream object.element - a Node object.public static void dump(PrintStream o, Node node, String level)
dump.
o - a PrintStream object.node - a Node object.level - a String object.public static void dump(PrintStream out, NodeList nodes)
dump.
out - a PrintStream object.nodes - a NodeList object.public static String innerXml(Node node)
node - a org$w3c$dom$Node object.String object.public static String innerXml(Node node, boolean instructions)
node - a org$w3c$dom$Node object.instructions - set to false to ignore processing instructions (on the first level)public static MXml.NodeIterator queryXPath(Node root, String query) throws XPathExpressionException
root - a Node object.query - a String object.XPathExpressionException - if any.public static MXml.ElementIterator queryXPathElements(Node root, String query) throws XPathExpressionException
root - a Node object.query - a String object.XPathExpressionException - if any.public static void trim(Element element)
element - a Element object.public static void carveOut(Element element)
element - a Element object.public static String normalizeName(String key)
key - a String object.public static CDATASection findCDataSection(Element a)
findCDataSection.
a - a Element object.CDATASection object.Copyright © 2016. All Rights Reserved.