Package com.ganteater.ae.util.xml.easyparser
package com.ganteater.ae.util.xml.easyparser
Lightweight, non-validating XML parsing with a simple in-memory node tree.
The primary entry point is EasyParser, which parses small XML payloads into
a mutable tree of Node instances. The implementation is intentionally
minimal and focuses on convenience for configuration-like documents rather than full XML compliance.
Core model
-
Noderepresents an element-like node with a tag name, attributes, and ordered child nodes. -
Text content is represented as a child
Nodewhose tag name isNode.TEXT_TEAG_NAME.Node.getInnerText()reads the first text child. -
Node.getXMLText()serializes a node tree back to XML.
Parsing behavior
- Leading
<?xml ... ?>headers are skipped by the stream-based parser. <!DOCTYPE ...>declarations are removed before parsing.-
XML comments (
<!-- ... -->) are converted into nodes with the tag nameComment. When serializing,Commentnodes are emitted as XML comments. - The parser does not perform DTD/XSD validation.
Utilities
-
NodeMappercan create missing elements along a/-separated path and set an attribute on the terminal element. -
EasyUtilsprovides small recursive helpers such as removing an attribute (for exampleNode.TAG_ID) across a subtree. ParserExceptionwraps errors from stream-based parsing.
Example
EasyParser parser = new EasyParser();
Node root = parser.getObject("<root><child id=\"1\">text</child></root>");
Node child = root.getNodes("child")[0];
String id = child.getAttribute("id");
String text = child.getInnerText();
String xml = root.getXMLText();