ElementTree module
This module contains functions for manipulating HTML or XML element trees described by ElementTree, including conversion to and from Strings, and a basic templating system.
Exceptions
- ExpectedChar - Expected character missing parsing XML
- InputError - Input error parsing XML
- NotLazy - The item to evaluate is not a generator
- UnexpectedChar - Unexpected character found parsing XML
- UnexpectedEnd - Unexpected end of data parsing XML
Functions
- Void addDataAt(ElementTree parent,String cdata,Int index) - Add text to an element
- Void addElementAt(ElementTree parent,ElementTree child,Int index) - Add a new child element
- Void addGeneratorAt(ElementTree parent,ElementTree() child,Int index) - Add a new child generator
- Int attrHash(String tohash) -
- ElementTree elementTree(String original,String rootelement="tree",Dict<String, [String]> whitelist=Dict::new(2, strHash),Dict<String, [String]> implicitend=Dict::new(2, strHash),[String] emptyels=createArray(1),Dict<String, ElementTree([Pair<String, String> ])> templates=Dict::new(2, strHash),Bool casesensitive=false,Bool sloppy=false,Bool lazytemplates=true) - Converts a String to an ElementTree.
- Void evaluateGenerator(ElementTree element,Int idx) - Evaluate a lazy element generator
- Maybe<Int> findElement(ElementTree block,String subname) - Get the index of a named sub-element from an element
- String getAllText(ElementTree outer) - Returns the text content of the element and children
- Maybe<String> getAttribute(ElementTree block,String attribute) - Get an attribute value from an element
- TinyDict<String, String> getAttributes(ElementTree block) - Get an element's attributes
- [Element] getElements(ElementTree block) - Get all child elements
- String getName(ElementTree block) - Get an element name
- [ElementTree] getSubtrees(ElementTree outer) - Get all child element trees
- String getText(ElementTree outer) - Returns the text content of the element
- Void lazyOutput(ElementTree etree,EmptyTagMode mode=OpenAndClose,Int indentlevel=0,UnicodeFormat uform=LiteralUTF8,HashSet<String> breakers=newHashSet(1, strHash),HashSet<String> emptyels=newHashSet(1, strHash),Void(String) outfn) - Print an ElementTree to a user-defined target
- Void lazyPrint(ElementTree etree,EmptyTagMode mode=OpenAndClose,Int indentlevel=0,UnicodeFormat uform=LiteralUTF8,HashSet<String> breakers=newHashSet(1, strHash),HashSet<String> emptyels=newHashSet(1, strHash)) - Print an ElementTree
- ElementTree newElement(String name,Int expectedchildren=0) - Create a new element
- Void pushData(ElementTree parent,String cdata) - Add text to the end of an element
- Void pushElement(ElementTree parent,ElementTree child) - Add a new child element to the end
- Void pushGenerator(ElementTree parent,ElementTree() child) - Add a new child generator to the end
- Void setAttribute(ElementTree element,String name,String value) - Set an attribute
- String simpleEncode(String invalue,Bool leavequotes=false,UnicodeFormat uform=LiteralUTF8) - HTML-escape a string
- String string(ElementTree etree,EmptyTagMode mode=OpenAndClose,Int indentlevel=0,UnicodeFormat uform=LiteralUTF8,HashSet<String> breakers=newHashSet(1, strHash),HashSet<String> emptyels=newHashSet(1, strHash)) - Convert an ElementTree to a String
- Int textSizeOfBlock(Element element) - Get the text length of an element
- Void unsetAttribute(ElementTree element,String name) - Unset an attribute
- Void unshiftData(ElementTree parent,String cdata) - Add text to the start of an element
- Void unshiftElement(ElementTree parent,ElementTree child) - Add a new child element to the start
- Void unshiftGenerator(ElementTree parent,ElementTree() child) - Add a new child generator to the start