- Simplified XML reader, writer, and data structure.
- Designed for working with purely hierarchical data.
- Exactly preserves data written in it. When reading outside xml, ignores whitespace used for formatting.
- Unlike normal HTML, the textual data of every element and property may be made up of only pure text.
- Elements may store children, but not as part of their textual content.
- To easily navigate the XML tree structure, you use objects called Filters which are passed to the
getChildren()
/getProperty()
functions. - Filters may be combined, and there are filters for looking at the child elements/properties.
- These filters can take their own filters, recursivly.
XMLElement rootElement = doc.getRootElement();
XMLElement child = rootElement
.getChild(
new NameFilter("Factor"),
new ValueFilter("32")
);
XMLElement rootElement = doc.getRootElement();
XMLElement child = rootElement
.getChild(
new NameFilter("Factor"),
new HasPropertyFilter(
new NameFilter("type"),
new ValueFilter("basic")
)
);
- Because JHierarchyXML is designed for the shortest possible code, asking for a child which does not exist will return a special case element or property.
- This special case has
null
for its name and value. - Asking for children/properties will return an empty list
- Since it has no children, asking for a child/property will return the special case again.
- As a result, you will always avoid
NullPointerException
s. - To see if the element/property actually exists, use the
exists()
function.
XMLElement rootElement = doc.getRootElement();
boolean exists = rootElement
.getChild(
new NameFilter("Factor")
).exists();
- I have to write this still. After I've done the unit tests, this will be updated.
- 2.1
- New
- You can write comments by adding them to XMLElements. They will not be read.
- New