[XML-SIG] no 'writexml' when building a domTree from ext.Sax2
aconrad.tlv at magic.fr
Thu Jul 29 10:55:30 CEST 2004
>>My idea here is to :
>>1- read an xml file
>>2- make modifications to it (delete nodes)
>>3- save it back to a file
>>The way I build my DOM tree is with :
>> from xml.dom.ext.reader import Sax2
> Why do you think you need to do this? Are you sure you don't want plain
> old minidom? For one thing, you're looking for minidom APIs on a 4DOM
> instance (well, almost: it's toxml() on minidom, not writexml() ).
Well, simply because on the official documentation says so :
And because after that, I need to traverse my tree as explained in the
same official documentation here :
But apparently, minidom doesn't seem to have any createTreeWalker
method. I haven't got into it very deep actually. And I'm a newby
My project is for generating a video playlist via a web-base interface
The originally created XML playlist used as a testing XML file and was
done before I got into the web-based stuff. And for generating a
playlist from scratch, I just wrote python scripts and used a
doc = xml.dom.minidom.Document()
and do some 'doc.appendChild(child)' for manipulation to build my xml.
After that, I saved the file using 'doc.writexml(indent="", newl="")'
which let me generate a playlist with no indentation and newline.
After the XML file is generated on the 'admin side', I send the playlist
on the 'player' that is doing a 'createTreeWalker' on the XML file and
pass through every node and read videos <video>some_file.mpg</video>.
Well, it's a little bit more complicated then that because I handle
scheduling and a lot more, but that gives you the big picture.
That's how I got there. So now, I'm getting my scripts back and adapting
them for my web-based application in mod_python to be able to easely
make modification to the playlist via a GUI. So now, I'm developping the
'edit playlist' part. So as a player would do, I'd do a
reader = Sax2.Reader()
doc = reader.fromStream(playlist_file)
then have a createTreeWalker that would traverse the playlist to display it.
I haven't got into the question of 'how am I going to create a new
playlist file from scratch ?' yet. I'd probably use the 'doc =
xml.dom.minidom.Document()' and have some traditionnal
'doc.appendChild(child)' to build the 1st element and then save the
file. Once the 1st node is written on disk, I'll parse the file again
using Sax2 to display it and be able to add more stuff to the playlist.
> Warning: 4DOM is very slow. It's claim to fame used to be compliance,
> but now it has been superseded in that regard by Andrew Clover's pxdom.
> I'm pretty sure I wouldn't recommend 4DOM to anyone for anything right
Well, I'm just reading the documentation. What would you recommand ?
Alexandre CONRAD - TLV
Research & Development
tel : +33 1 30 80 55 05
fax : +33 1 30 56 55 06
6, rue de la plaine
78860 - SAINT NOM LA BRETECHE
More information about the XML-SIG