Differences between revisions 2 and 3
Revision 2 as of 2007-09-13 18:33:24
Size: 376
Editor: GregMoore
Comment:
Revision 3 as of 2007-09-14 23:05:33
Size: 1053
Editor: GregMoore
Comment:
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:

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

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:

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

XmlRelatedExamples (last edited 2009-06-26 10:23:52 by 202)