From:
<Seb...@en...> - 2007-09-14 16:17:42
|
Jitendra Nair wrote: > The pure python does work ... out of the box, it works if you use methods that create XML documents from Elements, but not the other way round. > , I am using the one available here > http://effbot.org/downloads/elementtree-1.2.6-20050316.zip > > I unzipped and copied the "elementtree" subdirectory to jython/Lib directory > and here is an interactive session . > > D:\jython2.2>jython > Jython 2.2 on java1.5.0_12 > Type "copyright", "credits" or "license" for more information. > >>>> 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) >>>> > <html><head><title>Page Title</title></head><body bgcolor="#ffffff">Hello, World > !</body></html>>>> > > Regards > Jitendra Nair > > > > On 9/13/07, cyberco <cy...@me...> wrote: > >> I would like to use the excellent ElementTree for some simple XML >> work, but unfortunately it depends on the shared lib 'expat' so Jython >> can't import it. Or can it? Anybody here that succeeded? >> >> I've read that previous versions of elementtree had a way to avoid >> expat by using SimpleXMLTreeBuilder, but that class has been removed >> now (although the error message still says "No module named expat; use >> SimpleXMLTreeBuilder instead"). >> >> If elementtree is a no go (I hope not) what other XML parsing package >> (python) or lib (java) would you recommend? (I prefer the Python >> packages since those are generally much simpler to use.) >> >> Cheers, >> Berco >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... >> https://lists.sourceforge.net/lists/listinfo/jython-users >> >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |