Jython examples using Java XML classes

DocumentationAndEducation

TableOfContents


Examples related to Java XML classes using Jython will be here.

List of pages in this category:

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>>>> }}}