DOM text

Richard Lewis richardlewis at fastmail.co.uk
Fri Aug 26 05:56:25 EDT 2005


Hello Pythoners,

I'm currently writing some Python to manipulate a semi-structured XML
document. I'm using DOM (minidom) and I've got working code for
transforming the document to HTML files and for adding the 'structured'
elements which populate the higher regions of the tree (i.e. near the
root).

What I have to do next is write some code for working with the 'less
structured' elements towards the 'leaf ends' of the tree. These are
rather like little sub-documents and contain a mixture of text with
inline formatting (for links, font styles, headings, paragraphs etc.)
and objects (images, media files etc.).

I admit I haven't tried very much code yet, but I'm not sure how I'm
going to handle situations like: the user wants to insert a link in the
middle of a paragraph. How can I use the DOM to insert a node into the
middle of some text? Am I right in thinking that the DOM will reference
a whole text node but nothing smaller?

Any thoughts or suggestions would be very welcome!

Cheers,
Richard



More information about the Python-list mailing list