XML ElementTree module for Skulpt
This module is an attempt to reproduce some of the functionality provided by the Python XML ElementTree module for use in Skulpt.
These are the primary methods for parsing and displaying XML strings. parse and XML are aliases for fromstring. dump is an alias for tostring.
- tag
- text
- attrib
- clear()
- get()
- items()
- keys()
- set()
- append()
- extend()
- find()
- findall()
- findtext()
- insert()
- iter()
- iterfind()
- itertext()
It is also possible to create elements and subelements using the Element constructor and SubElement method respectively.
Complete spec of the Python 2.x XML ElementTree implementation can be found at https://docs.python.org/2/library/xml.etree.elementtree.html.
XPath, read/write files, tostring encoding.
- tail
- insert()
- makeelement()
- remove()
The example.html file shows an example of basic usage. You'll need to change paths to skulpt and the xml module first.
Add the xml.sk specific Skulpt configuration options
// tell Skulpt where to find xml.sk
Sk.externalLibraries = {
xml : {
path : '/path/to/xml.sk/__init__.js'
},
'xml.etree' : {
path : '/path/to/xml.sk/etree/__init__.js'
},
'xml.etree.ElementTree' : {
path : '/path/to/xml.sk/etree/ElementTree.js'
}
};Point your browser to your html page and have fun!
Assumes browser support for DOMParser.