471,350 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

XML DOM, but in chunks

I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?
Alternatively, are there other ways that would allow one to parse out
a record at a time and maintain some nice ways of accessing the
elements within the record?

Thanks,
Sean

Oct 31 '07 #1
5 1114
On Wed, 31 Oct 2007 20:24:43 +0000, Sean Davis wrote:
I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?
Have you tried `iterparse()`?

Ciao,
Marc 'BlackJack' Rintsch
Oct 31 '07 #2

On 31 okt 2007, at 21.24, Sean Davis wrote:
I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?
Alternatively, are there other ways that would allow one to parse out
a record at a time and maintain some nice ways of accessing the
elements within the record?

Thanks,
Sean

--
http://mail.python.org/mailman/listinfo/python-list
You need a Python (or other language) implementation of the SAX API
----------------------------------
Skinheads are so tired of immigration, that they are going to move to
a country that don't accept immigrants!
Tommy Nordgren
to************@comhem.se

Oct 31 '07 #3

On 31 okt 2007, at 22.36, Tommy Nordgren wrote:
>
On 31 okt 2007, at 21.24, Sean Davis wrote:
>I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?
Alternatively, are there other ways that would allow one to parse out
a record at a time and maintain some nice ways of accessing the
elements within the record?

Thanks,
Sean

--
http://mail.python.org/mailman/listinfo/python-list
You need a Python (or other language) implementation of the SAX API
The module you need is xml.sax
----------------------------------
Skinheads are so tired of immigration, that they are going to move to
a country that don't accept immigrants!
Tommy Nordgren
to************@comhem.se

Nov 1 '07 #4
On Oct 31, 4:43 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.netwrote:
On Wed, 31 Oct 2007 20:24:43 +0000, Sean Davis wrote:
I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?

Have you tried `iterparse()`?

Ciao,
Marc 'BlackJack' Rintsch
Detailed docs at http://effbot.org/zone/element-iterparse.htm

George

Nov 1 '07 #5
Tommy Nordgren wrote:
>On 31 okt 2007, at 21.24, Sean Davis wrote:
>>I have some very large XML files that are basically recordsets. I
would like to access each record, one-at-a-time, and I particularly
like the ElementTree library for accessing the data. Is there a way
to have ElementTree read only one record of the data at a time?
Alternatively, are there other ways that would allow one to parse out
a record at a time and maintain some nice ways of accessing the
elements within the record?

Thanks,
Sean
You need a Python (or other language) implementation of the SAX API
The module you need is xml.sax
That's unlikely - few people "need" SAX. If they think they do, they just
don't know the alternatives. I think iterparse() is what he was looking for.

Stefan
Nov 1 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Guy Erez | last post: by
reply views Thread by I Decker | last post: by
1 post views Thread by Nawaz Ijaz | last post: by
6 posts views Thread by MackS | last post: by
1 post views Thread by Al | last post: by
1 post views Thread by mdefoor | last post: by
3 posts views Thread by codemannh | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.