xml element tree to html problem

akameswaran at gmail.com akameswaran at gmail.com
Tue Apr 4 16:22:01 EDT 2006


are you using PyXML?
If this is a simple one to one relationship with dependence on order,
I'd forgo the whole PyXML, read the file line by line, and replace tags
as appropriate.  You may have to do some simple checkin, in case there
is n <object> <name>object</name>


Otherwise, have fun with the parsers - nothing is painless is SAX or
DOM.

as far as simple translation?  once you have tokenized or used PyXML to
get the elements, something like?

for tag in listofTags:
  if tagDictionary.has_key(tag):
      doSomething(tagDictionary[tag])


IMHO - PyXML is a great tool, but for something like simple
substitution, it's so so much overkill. For simple processing tasks
like this I almost always just treat it as a text file.  I resort to
PyXML when things like heirarchy are important.  Hope this  helps




More information about the Python-list mailing list