ElementTree::elementTree(3) Converts a String to an ElementTree.

SYNOPSIS

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 )

ARGUMENTS

original The String to convert

rootelement The name of the root element to use as a parent. Optional, defaulting to "tree".

whitelist A whitelist dictionary of allowed elements. The key is the element name, the value is a list of allowed attribute names for that element. If the key is "*" then all elements are allowed (though you may wish to explicitly specify others to override the attributes specified for "*"). If the value list contains "*" then all attributes are allowed. Optional, defaulting to the empty dictionary, which makes this function strip all tags from the string as it imports it.

implicitend A dictionary of tags that close elements other than their own. In XML, this should be an empty dictionary - it is used to parse HTML and other SGML dialects that allow implicit closing. The key is the element to close, and the value is a list of tags that will close that element, represented as "tagname" for an opening tag, and "/tagname" for a closing tag. For example, the implicit ending list for the "li" element in HTML is ["li","/ul","/ol"]
 This is optional and defaults to the empty dictionary, which is correct for XML strings.

emptyels A list of elements that are allowed to be empty (i.e. a singleton tag such as <br> is allowed). This is very important when importing HTML or other SGML dialects where a singleton tag might not differ in appearance from a normal opening tag. This is optional and defaults to the empty list. When processing XML, this list should always be empty, as it is never ambiguous.

templates A dictionary of elements that are really calls to templating functions. The key is the element name, and the value is a function that takes a list of pairs of attributes and returns an ElementTree
 This can be used for templating, or for converting one form of XML into another. This is optional and defaults to the empty dictionary.

casesensitive Should conversion be case-sensitive? If this is false, all whitelist , implicitend , emptyels and templates keys and values will be treated as case-insensitive, and all elements will be converted to lowercase. In XML, this should be set to true, which will give some increase in processing speed. This parameter is optional and the default value is false.

sloppy Use 'sloppy' processing, which attempts to make a reasonable guess at the meaning of broken input. It may guess entirely wrongly, of course, and in some circumstances it may still throw an Exception. Optional, defaulting to false (where it should be left if possible!). This argument is ignored if the templates dictionary has any contents.

DESCRIPTION

Converts a String to an ElementTree. Several additional parameters may be passed to control various aspects of the conversion.

AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others ([email protected]). For further information see http://kayalang.org/

LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.

RELATED

ElementTree.string(3kaya)