Jython examples using Java XML classes
Examples related to Java XML classes using Jython will be here.
List of pages in this category:
- Something simple using 4dom
- Something else simple Jdom
- Others ?
- and of course Java SDK
Element tree
Here is a simple example. info on element tree is at http://effbot.org/zone/element-index.htm
Download element tree from http://effbot.org/downloads/
{{{from elementtree import ElementTree as ET root = ET.Element("html") head = ET.SubElement(root, "head") title = ET.SubElement(head, "title") title.text = "Page Title" body = ET.SubElement(root, "body") body.set("bgcolor", "#ffffff") body.text = "Hello, World!" tree = ET.ElementTree(root) tree.write("page.xhtml") import sys tree.write(sys.stdout)
which produces: {{{ <html><head><title>Page Title</title></head><body bgcolor="#ffffff">Hello, World !</body></html>>>> }}}