Re: XML parsing: SAX/expat & yield

2010-08-04 Thread kj
In Peter Otten <__pete...@web.de> writes: >How about >http://effbot.org/zone/element-iterparse.htm#incremental-parsing Exactly! Thanks! ~K -- http://mail.python.org/mailman/listinfo/python-list

Re: XML parsing: SAX/expat & yield

2010-08-04 Thread Peter Otten
kj wrote: > I want to write code that parses a file that is far bigger than > the amount of memory I can count on. Therefore, I want to stay as > far away as possible from anything that produces a memory-resident > DOM tree. > > The top-level structure of this xml is very simple: it's just a > v

XML parsing: SAX/expat & yield

2010-08-04 Thread kj
he generator sense) the next record, thereby returning control to the caller; the caller can process the record, delete it from memory, and return control to the parser-iterator; once parser-iterator regains control, it repeats this sequence starting where it left off. The problem, as I see it, is that SAX

Re: expat parsing error

2010-06-02 Thread kak...@gmail.com
On 2 Ιούν, 03:47, John Machin wrote: > On Jun 2, 1:57 am, "kak...@gmail.com" wrote: > > > > > > > On Jun 1, 11:12 am, "kak...@gmail.com" wrote: > > > > On Jun 1, 11:09 am, John Bokma wrote: > > > > > "kak...@gmail.com" writes: > > > > > On Jun 1, 10:34 am, Stefan Behnel wrote: > > > > >> kak.

Re: expat parsing error

2010-06-01 Thread John Machin
On Jun 2, 1:57 am, "kak...@gmail.com" wrote: > On Jun 1, 11:12 am, "kak...@gmail.com" wrote: > > > > > On Jun 1, 11:09 am, John Bokma wrote: > > > > "kak...@gmail.com" writes: > > > > On Jun 1, 10:34 am, Stefan Behnel wrote: > > > >> kak...@gmail.com, 01.06.2010 16:00: > > > > >> > how can i f

Re: expat parsing error

2010-06-01 Thread kak...@gmail.com
On Jun 1, 11:12 am, "kak...@gmail.com" wrote: > On Jun 1, 11:09 am, John Bokma wrote: > > > > > "kak...@gmail.com" writes: > > > On Jun 1, 10:34 am, Stefan Behnel wrote: > > >> kak...@gmail.com, 01.06.2010 16:00: > > > >> > how can i fix it, how to "ignore" the headers and parse only > > >> > t

Re: expat parsing error

2010-06-01 Thread kak...@gmail.com
On Jun 1, 11:09 am, John Bokma wrote: > "kak...@gmail.com" writes: > > On Jun 1, 10:34 am, Stefan Behnel wrote: > >> kak...@gmail.com, 01.06.2010 16:00: > > >> > how can i fix it, how to "ignore" the headers and parse only > >> > the XML? > > >> Consider reading the answers you got in the last t

Re: expat parsing error

2010-06-01 Thread John Bokma
"kak...@gmail.com" writes: > On Jun 1, 10:34 am, Stefan Behnel wrote: >> kak...@gmail.com, 01.06.2010 16:00: >> >> > how can i fix it, how to "ignore" the headers and parse only >> > the XML? >> >> Consider reading the answers you got in the last thread that you opened >> with exactly this quest

Re: expat parsing error

2010-06-01 Thread kak...@gmail.com
On Jun 1, 10:34 am, Stefan Behnel wrote: > kak...@gmail.com, 01.06.2010 16:00: > > > how can i fix it, how to "ignore" the headers and parse only > > the XML? > > Consider reading the answers you got in the last thread that you opened > with exactly this question. > > Stefan That's exactly, what

Re: expat parsing error

2010-06-01 Thread Stefan Behnel
kak...@gmail.com, 01.06.2010 16:00: how can i fix it, how to "ignore" the headers and parse only the XML? Consider reading the answers you got in the last thread that you opened with exactly this question. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: expat parsing error

2010-06-01 Thread John Bokma
ine 460, in doRead >> >     return self.protocol.dataReceived(data) >> >   File "stdiodemo.py", line 419, in dataReceived >> >     p.Parse(line, 1) >> > xml.parsers.expat.ExpatError: syntax error: line 1, column 0 >> >> > The XML Message is coming

Re: expat parsing error

2010-06-01 Thread kak...@gmail.com
ived(data) > >   File "stdiodemo.py", line 419, in dataReceived > >     p.Parse(line, 1) > > xml.parsers.expat.ExpatError: syntax error: line 1, column 0 > > > The XML Message is coming in the form of: > > > POST /test/pcp/Listener HT

Re: expat parsing error

2010-06-01 Thread John Bokma
rs.expat.ExpatError: syntax error: line 1, column 0 > > > The XML Message is coming in the form of: > > POST /test/pcp/Listener HTTP/1.1 Does Expat get this line as well? If so, that's the reason why you get an error at line 1, column 0. -- John Bokma

expat parsing error

2010-06-01 Thread kak...@gmail.com
Hi i'm doing the following: def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) class SimpleServer(LineReceiver): # Using Twisted def connectionMade(self):

expat parsing error

2010-06-01 Thread kak...@gmail.com
Hi i'm doing the following: def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) class SimpleServer(LineReceiver): # Using Twisted def connectionMade(self):

Re: expat having problems with entities (&)

2009-12-11 Thread nnguyen
On Dec 11, 4:39 pm, Rami Chowdhury wrote: > On Fri, Dec 11, 2009 at 13:23, nnguyen wrote: > > > Any ideas on any expat tricks I'm missing out on? I'm also inclined to > > try another parser that can keep the string together when there are > > entities, or a

Re: expat having problems with entities (&)

2009-12-11 Thread nnguyen
On Dec 11, 4:23 pm, nnguyen wrote: > I need expat to parse this block of xml: > > > c-P&P > LOT 3677 > (F) > > > I need to parse the xml and return a dictionary that follows roughly > the same layout as the xml. Currently the code for the class han

Re: expat having problems with entities (&)

2009-12-11 Thread Rami Chowdhury
On Fri, Dec 11, 2009 at 13:23, nnguyen wrote: > > Any ideas on any expat tricks I'm missing out on? I'm also inclined to > try another parser that can keep the string together when there are > entities, or at least ampersands. IIRC expat explicitly does not guarantee that

expat having problems with entities (&)

2009-12-11 Thread nnguyen
I need expat to parse this block of xml: c-P&P LOT 3677 (F) I need to parse the xml and return a dictionary that follows roughly the same layout as the xml. Currently the code for the class handling this is: class XML2Map(): def __init__(self): """ &quo

Re: Python libexpat and EXPAT are same/Different?

2009-08-20 Thread Stefan Behnel
hari wrote: > Am very new to XML, I have a query, Does Python libexpat and EXPAT > are same or they are diffrent? Depends on what you mean with "EXPAT". Python's expat module that you can find in the standard library is the well known non-validating XML parser originally w

Python libexpat and EXPAT are same/Different?

2009-08-20 Thread hari
Hi all, Am very new to XML, I have a query, Does Python libexpat and EXPAT are same or they are diffrent? Thanks in advance. Regards, Hari -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Stefan Behnel
Chris Rebert wrote: > On Fri, Jan 23, 2009 at 11:19 AM, aha wrote: >> I've been charged with developing an XML configuration file format, >> for one of the applications that my company develops. >> [...] >> I am still trying to determine the >> best XML parser API to use. I would love to use XPAT

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Chris Rebert
ay to go, but then I ran across the Recipes of Wai > Yip Tung > > http://code.activestate.com/recipes/534109/ > > > and John Bair, Christoph Dietze from the second edition of the Python > cookbook. > > Wai's implementation uses thes SAX parser and John and Christoph

Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread aha
oph Dietze from the second edition of the Python cookbook. Wai's implementation uses thes SAX parser and John and Christoph's implementation uses Expat API. In the end what I really want is to transform the XML into an object that looks like config.component.set

Re: Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread MRAB
On Sep 11, 4:48 pm, Manuel Ebert <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Ah, well. Don't know whether it meets your aesthetic standards, but: >  >>> my_list = ['tree', 'hug', 'flower', 'hug', 'bear', 'run'] >  >>> my_list[0:len(a):2] > ['tree', 'flower', 'be

Re: Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread andy_westken
lem is that the second > >> parameter you passed to start_element is not a dictionary at all (the > >> clue is in the "AttributeError: 'LIST' object" ...). > > >>  >>> d = ['tree', 'house'] > >>  >>> start_elemen

Re: Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread Manuel Ebert
sed to start_element is not a dictionary at all (the clue is in the "AttributeError: 'LIST' object" ...). >>> d = ['tree', 'house'] >>> start_element("Thing", d) Thing : AttributeError: 'list' object has no attribute &#x

Re: Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread andy_westken
gt;>> d = {'tree': 'hug', 'flower' : 'eat'} >  >>> start_element("Thing", d) > Thing :   flower="eat"  tree="hug" > > Manuel > > On Sep 11, 2008, at 4:21 PM, [EMAIL PROTECTED] wrote: > > >

Re: Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread Manuel Ebert
ng", d) Thing : flower="eat" tree="hug" Manuel On Sep 11, 2008, at 4:21 PM, [EMAIL PROTECTED] wrote: Hi I'm new to Python and trying to pick up good, idiomatic usage right from the offset. As I was familiar with Expat from C++ (directly and via expatpp) I'm try

Enumerating ordered expat attributes with tuplets?

2008-09-11 Thread andy_westken
Hi I'm new to Python and trying to pick up good, idiomatic usage right from the offset. As I was familiar with Expat from C++ (directly and via expatpp) I'm trying to write a little script - using xml.parsers.expat - to search and replace XML attribute values. As I want the attribut

Re: XML Parsing: Expat Error

2008-07-19 Thread Fredrik Lundh
Gerth, William D wrote: Hey all, I’m simply trying to get my feet wet with XML parsing, and I tried to just do something simple with ElementTree, just throw the XML tags from a file into a list. The code is as follows (and may be wrong): ... xml.parsers.expat.ExpatError: no element found:

XML Parsing: Expat Error

2008-07-17 Thread Gerth, William D
Hey all, I'm simply trying to get my feet wet with XML parsing, and I tried to just do something simple with ElementTree, just throw the XML tags from a file into a list. The code is as follows (and may be wrong): import glob import xml.etree.ElementTree as ET tree = ET.parse('nameofFileh

Re: XML expat error

2008-02-28 Thread Marc 'BlackJack' Rintsch
On Thu, 28 Feb 2008 12:37:10 -0800, dirkheld wrote: >> Yes of course: handle the exception instead of letting it propagate to the >> top level and ending the program. > > Ehm, maybe a stupid question... how. I'm rather new to python and I > never user error handling. Then you should work through

Re: XML expat error

2008-02-28 Thread Stefan Behnel
dirkheld wrote: > On 28 feb, 08:18, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Wed, 27 Feb 2008 14:02:25 -0800, dirkheld wrote: >>> Something strange here. The xml file causing the problem has only 361 >>> lines. Isn't there a way to catch this error, ignore it and continu >>> with t

Re: XML expat error

2008-02-28 Thread dirkheld
On 28 feb, 08:18, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 27 Feb 2008 14:02:25 -0800, dirkheld wrote: > > Something strange here. The xml file causing the problem has only 361 > > lines. Isn't there a way to catch this error, ignore it and continu > > with the rest of the othe

Re: XML expat error

2008-02-27 Thread Marc 'BlackJack' Rintsch
On Wed, 27 Feb 2008 14:02:25 -0800, dirkheld wrote: > Something strange here. The xml file causing the problem has only 361 > lines. Isn't there a way to catch this error, ignore it and continu > with the rest of the other files? Yes of course: handle the exception instead of letting it propagate

Re: XML expat error

2008-02-27 Thread dirkheld
On 27 feb, 17:18, "Richard Brodie" <[EMAIL PROTECTED]> wrote: > "dirkheld" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > xml.parsers.expat.ExpatError: not well-formed (invalid token): line > > 554, column 20 > > > I guess that the element I try to read or the XML(which would

Re: XML expat error

2008-02-27 Thread Richard Brodie
"dirkheld" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > xml.parsers.expat.ExpatError: not well-formed (invalid token): line > 554, column 20 > > I guess that the element I try to read or the XML(which would be > strange since they have been created with the same code) can't ben

XML expat error

2008-02-27 Thread dirkheld
Hi, I have written a piece of code that reads all xml files in a directory in onder to retrieve one element in each of these files. All files have the same XML structure. After file 123 I receive the following error : xml.parsers.expat.ExpatError: not well-formed (invalid token): line 554, column

Re: build a hierarchical tree, without using DOM,schema, and sax using expat parser and c

2007-11-16 Thread Stefan Behnel
Wildemar Wildenburger wrote: > sharan wrote: >> I've been experimenting with the jclark's expat parser. I compiled it >> on >> linux, and it works just great. However, finding tags and data by >> implementing the callback functions in c language is cumbers

Re: build a hierarchical tree, without using DOM,schema, and sax using expat parser and c

2007-11-16 Thread Wildemar Wildenburger
sharan wrote: > I've been experimenting with the jclark's expat parser. I compiled it > on > linux, and it works just great. However, finding tags and data by > implementing the callback functions in c language is cumbersome. > Has anybody written code that uses the e

build a hierarchical tree, without using DOM,schema, and sax using expat parser and c

2007-11-16 Thread sharan
I've been experimenting with the jclark's expat parser. I compiled it on linux, and it works just great. However, finding tags and data by implementing the callback functions in c language is cumbersome. Has anybody written code that uses the expat callback's in such a wa

Re: expat error, help to debug?

2007-08-28 Thread Andreas Lobinger
Aloha, Andreas Lobinger wrote: > Andreas Lobinger wrote: >> Lawrence D'Oliveiro wrote: >>> In message <[EMAIL PROTECTED]>, Andreas Lobinger wrote: Anyone any idea where the error is produced? > The registered Handler has to return a (integer) value. > Would have been nice if this had been men

Re: expat error, help to debug?

2007-08-28 Thread Andreas Lobinger
Aloha, Andreas Lobinger wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Andreas Lobinger wrote: >>> Anyone any idea where the error is produced? ... to share my findings with you: def ex(self,context,baseid,n1,n2): print "x",context,n1,n2 return 1 T

Re: expat error, help to debug?

2007-08-27 Thread Andreas Lobinger
e chapter e book Traceback (most recent call last): File "pbxml.py", line 29, in ? fromxml(sys.argv[1]) File "pbxml.py", line 24, in fromxml p.ParseFile(file(fname)) TypeError: an integer is required which shows me that the error is caused after parsing the /book ... B

Re: expat error, help to debug?

2007-08-26 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Andreas Lobinger wrote: > Anyone any idea where the error is produced? Do you want to try adding an EndElementHandler as well, just to get more information on where the error might be happening? -- http://mail.python.org/mailman/listinfo/python-list

expat error, help to debug?

2007-08-23 Thread Andreas Lobinger
Aloha, i'm trying to write an xml filter, that extracts some info about an .xml document (with external entities), esp. start elements and external entities. The document is a DOCBOOK xml and afacs well formed and passes our docbook toolchain (dblatex etc.). My parser is (very simple): [115] scyl

Re: expat parser

2007-05-28 Thread Stefan Behnel
> Character data: u'\n' > Character data: u'EAFLTQKQKVGELKDDDFEKISELGAGNGGVVFKVSHKPSGLVMARKLIH' > ... > End element: sequence > ... > > Is there a way to have the character data together in one string? I > guess it should not be difficult, but I can't do it. Each time the > parse reads a line, return a line, and I want to have it in one > variable. Any reason you are using expat and not cElementTree's iterparse? Stefan -- http://mail.python.org/mailman/listinfo/python-list

expat parser

2007-05-27 Thread Sebastian Bassi
I have this code: import xml.parsers.expat def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p = xml.parsers.expat.ParserCreate() p.StartElementHandler = start_e

Re: xml.sax.xmlreader and expat

2006-06-27 Thread Stefan Behnel
Fredrik Lundh wrote: > Gary Robinson wrote: > >> We're using xml.sax.xmlreader in our app (http://www.goombah.com, >> which is written in Python). >> >> In Python 2.3.x, does that use the C-language expat under the hood? > > yes. > >> The reas

Re: xml.sax.xmlreader and expat

2006-06-27 Thread Fredrik Lundh
Gary Robinson wrote: > We're using xml.sax.xmlreader in our app (http://www.goombah.com, which > is written in Python). > > In Python 2.3.x, does that use the C-language expat under the hood? yes. > The reason I'm asking is because we're wondering if

xml.sax.xmlreader and expat

2006-06-27 Thread Gary Robinson
Hi, We're using xml.sax.xmlreader in our app (http://www.goombah.com, which is written in Python). In Python 2.3.x, does that use the C-language expat under the hood? The reason I'm asking is because we're wondering if we can speed up the parsing significantly. Thanks in

Re: expat

2006-02-28 Thread Katja Suess
Merci à Frederik et Jarek! According to your hints I did tests with a different coding and another option in OpenOffice 'Size optimization for XML format'. Went fine! - Back to my files from yesterday the same proper converting... uups Anyway, it's running! Katja -- http://mail.python.org/mailman

Re: expat

2006-02-27 Thread Jarek Zgoda
.expat is a standard module that probably has no errors. > So what could cause this error message?? Malformed XML document, perhaps. This may be anything, that expat doesn't like (i.e. wrong encoding, cp1252 declared as latin-1, document declared as utf-8 but with BOM, and so on). -- Jarek

Re: expat

2006-02-27 Thread Fredrik Lundh
Katja Suess wrote: > may I have a hint what the problem is in my situation? > Is it a syntax error in sweetone.odt or in xml.parsers.expat? > xml.parsers.expat.ExpatError: syntax error: line 1, column 0 it's a problem with the file you're parsing (either because it's not a valid XML file, or bec

expat

2006-02-27 Thread Katja Suess
Hi, may I have a hint what the problem is in my situation? Is it a syntax error in sweetone.odt or in xml.parsers.expat? Same problem with different file instead of sweetone.odt means that it's not the file that has a syntax error. xml.parsers.expat is a standard module that probably has no errors

Re: Expat - how to UseForeignDTD

2005-10-20 Thread B Mahoney
I needed to set Entity Parsing, such as parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_ALWAYS ) -- http://mail.python.org/mailman/listinfo/python-list

Expat - how to UseForeignDTD

2005-10-19 Thread B Mahoney
I have a simple Kid template document: http://www.w3.org/1999/xhtml"; xmlns:py="http://purl.org/kid/ns#"; > ... (snip) This runs as expected but now I would like to load a DTD without tampering with this xml file In the expat parser __init__ after setting other hand

Re: Can I make the Python build use an already-installed version of Expat?

2005-07-19 Thread Steve Juranich
On 7/19/05, Bernhard Herzog <[EMAIL PROTECTED]> wrote: > This sounds like this bugreport on sourceforge: > http://python.org/sf/1075984 Thanks! I applied the workaround posted by `bos' and things seem to work now. -- Steve Juranich Tucson, AZ USA -- http://mail.python.org/mailman/listinfo/pyth

Re: Can I make the Python build use an already-installed version of Expat?

2005-07-19 Thread Bernhard Herzog
Steve Juranich <[EMAIL PROTECTED]> writes: > I'm running into problems where Python and VTK both ship with their > own distribution of the Expat parser. As long as you never use the > Python XML package, everything is fine. But if you try using the > Python XML parser aft

Can I make the Python build use an already-installed version of Expat?

2005-07-19 Thread Steve Juranich
I'm running into problems where Python and VTK both ship with their own distribution of the Expat parser. As long as you never use the Python XML package, everything is fine. But if you try using the Python XML parser after doing an `import vtk', a nice little message saying "Seg

Re: Bug in Elementtree/Expat

2005-05-20 Thread uche . ogbuji
""" > Most examples in the book do not include such a declaration and yet are > properly rendered by Internet Explorer. > Is it mandatory and why is it that Expat crashes on it? It's not mandatory but it's probably good practice to make the document self-contain

Re: Bug in Elementtree/Expat

2005-05-18 Thread Richard Brodie
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Most examples in the book do not include such a declaration and yet are > properly rendered by Internet Explorer. > Is it mandatory and why is it that Expat crashes on it? It's not mandatory but it's proba

Re: Bug in Elementtree/Expat

2005-05-17 Thread alainpoint
yet are properly rendered by Internet Explorer. Is it mandatory and why is it that Expat crashes on it? Alain -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in Elementtree/Expat

2005-05-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I use Elementtree to parse an elementary SVG file (in fact, it is one > of the examples in the "SVG essentials" book). More precisely, it is > the fig0201.svg file in the second chapter. > The contents of the file are as follows (i hope it will be rendered > correctly):

Re: PyXML/expat and the empty elements

2005-05-17 Thread Armin Steinhoff
Armin Steinhoff wrote: > > > Hi all, > > is it possible to get the name of an empty element specified > by ... the expat parser seems only to recognize > the form > > Regards > > Armin Ok ... found the root of the problem. The expat parser is OK

PyXML/expat and the empty elements

2005-05-17 Thread Armin Steinhoff
Hi all, is it possible to get the name of an empty element specified by ... the expat parser seems only to recognize the form Regards Armin -- http://mail.python.org/mailman/listinfo/python-list

Bug in Elementtree/Expat

2005-05-17 Thread alainpoint
Hello, I use Elementtree to parse an elementary SVG file (in fact, it is one of the examples in the "SVG essentials" book). More precisely, it is the fig0201.svg file in the second chapter. The contents of the file are as follows (i hope it will be rendered correctly): http://www.w3.org/TR/2001/RE

freeze and expat

2005-04-21 Thread Operation Latte Thunder
I am playing around with jabberpy, and on a lark decided to try to freeze one of the included samples, test_client.py The freeze/build worked fine, but when I attempted to run the resulting binary, I got an error hinting that it couldn't find parsers.expat: canal:/home/chris/build% ./test_client