Thread
:
Python help please. Trying to write XML data
View Single Post
clasificado
2010-07-27 , 11:17
Posts: 466 | Thanked: 180 times | Joined on Feb 2010
#
6
im not an experienced python developer, but in other platforms there are two ways to read and write xml data without using a simple stream: dom and sax.
with dom, you talk to the entire document, load it in memory, modify what you want and save it again where you want, the whole document. This is the "default" expected behaviour because of the nature of xml, that is a document based data storage and is not optimized for cherry pick access, but for a coherent multidimensional human readable structure.
the alternative is to use sax, that lets you read (and write) the xml from a parser point of view, in a way where the nodes comes in a stream like fashion so you dont need to read the entire document if your element is at the start of the xml.
in my experience, a situation that a document based read/save doesnt fits your needs could fall into two categories:
- you need to manage a really big xml of data (so a whole read/save is a several seconds stress operation), here is ok to use sax
- you need to read and write your xml a lot, for procedural storage. like saving your current gps position or a log or a status report. then you must consider the use of SQLite in the place of a simple XML, because the default behaviour of a rmdb is to save only the bytes needed as you wants
hope this helps
Last edited by clasificado; 2010-07-27 at
11:19
.
Quote & Reply
|
clasificado
View Public Profile
Send a private message to clasificado
Find all posts by clasificado