Re: parsing multiple root element XML into text

2014-05-12 Thread Peter Otten
Percy Tambunan wrote: > On Friday, May 9, 2014 4:02:42 PM UTC+7, Chris Angelico wrote: >> On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan >> wrote: >> >> > Hai, I would like to parse this multiple root element XML >> >> >> >> Easy fix might be to wrap it in and , which will give >> >> you a

Re: parsing multiple root element XML into text

2014-05-11 Thread Percy Tambunan
On Friday, May 9, 2014 4:02:42 PM UTC+7, Chris Angelico wrote: > On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan > wrote: > > > Hai, I would like to parse this multiple root element XML > > > > Easy fix might be to wrap it in and , which will give > > you a new root. Would that help? > > >

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Burak Arslan, 09.05.2014 18:52: > On 05/09/14 16:55, Stefan Behnel wrote: >> ElementTree has gained a nice API in >> Py3.4 that supports this in a much saner way than SAX, using iterators. >> Basically, you just dump in some data that you received and get back an >> iterator over the elements (and

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 20:04: > I think the worst part of XML is that you can't parse it without a DTD > or schema. Nonsense. > I was very hopeful about json until I discovered they require the parser > to dynamically support five different character encodings. > > XML at least standardized

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > How do you specify the encoding of sexprs? How can you require that an > attribute value must match the value of an id-attribute? or whatever > insanely complex integrity rule that XML Schemas lets you express? And > so on. I don't suppose there is a universal schema language

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> which does an exact traversal of potential the DOM tree... (assuming a >> DOM is even defined on a non well-formed XML document). >> >> Anyway, my point was only to warn the OP that he is not doing XML. > > I consider that one of the multitude of fl

Re: parsing multiple root element XML into text

2014-05-09 Thread Burak Arslan
On 05/09/14 16:55, Stefan Behnel wrote: > ElementTree has gained a nice API in > Py3.4 that supports this in a much saner way than SAX, using iterators. > Basically, you just dump in some data that you received and get back an > iterator over the elements (and their subtrees) that it generated fro

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > which does an exact traversal of potential the DOM tree... (assuming a > DOM is even defined on a non well-formed XML document). > > Anyway, my point was only to warn the OP that he is not doing XML. I consider that one of the multitude of flaws in XML. Compare that with the

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> Sometimes the XML elements come through a pipe as an endless >>> sequence. You can still use the wrapping technique and a SAX parser. >>> However, the other option is to write a tiny XML scanner that >>> identifies the en

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Stefan Behnel : > ElementTree has gained a nice API in Py3.4 that supports this in a > much saner way than SAX, using iterators. Good to know. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Marko Rauhamaa, 09.05.2014 14:38: > Marko Rauhamaa: >> Alain Ketterlin: >>> Marko Rauhamaa writes: Sometimes the XML elements come through a pipe as an endless sequence. You can still use the wrapping technique and a SAX parser. However, the other option is to write a tiny XML scanne

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Marko Rauhamaa : > Alain Ketterlin : > >> Marko Rauhamaa writes: >>> Sometimes the XML elements come through a pipe as an endless >>> sequence. You can still use the wrapping technique and a SAX parser. >>> However, the other option is to write a tiny XML scanner that >>> identifies the end of ea

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > Marko Rauhamaa writes: >> Sometimes the XML elements come through a pipe as an endless >> sequence. You can still use the wrapping technique and a SAX parser. >> However, the other option is to write a tiny XML scanner that >> identifies the end of each element. Then, you can

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Marko Rauhamaa writes: > Alain Ketterlin : > >> Technically speaking, this is not a well-formed XML document (it is a >> well-formed external general parsed entity, though). If you have other >> XML processors in your workflow, they will/should reject it. > > Sometimes the XML elements come throu

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Alain Ketterlin : > Technically speaking, this is not a well-formed XML document (it is a > well-formed external general parsed entity, though). If you have other > XML processors in your workflow, they will/should reject it. Sometimes the XML elements come through a pipe as an endless sequence.

Re: parsing multiple root element XML into text

2014-05-09 Thread Alain Ketterlin
Percy Tambunan writes: > Hai, I would like to parse this multiple root element XML > > [...] > > [...] > Technically speaking, this is not a well-formed XML document (it is a well-formed external general parsed entity, though). If you have other XML processors in your workflow, they will/sh

Re: parsing multiple root element XML into text

2014-05-09 Thread Chris Angelico
On Fri, May 9, 2014 at 7:13 PM, Stefan Behnel wrote: > Chris Angelico, 09.05.2014 11:02: >> On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: >>> Hai, I would like to parse this multiple root element XML >> >> Easy fix might be to wrap it in and , which will give >> you a new root. > > Elemen

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Chris Angelico, 09.05.2014 11:02: > On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: >> Hai, I would like to parse this multiple root element XML > > Easy fix might be to wrap it in and , which will give > you a new root. ElementTree's XMLParser() can be use efficiently for this. Something

Re: parsing multiple root element XML into text

2014-05-09 Thread Marko Rauhamaa
Percy Tambunan : > Hai, I would like to parse this multiple root element XML How about creating a file-like object that wraps the multi-root file into a single-root document? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Chris Angelico
On Fri, May 9, 2014 at 6:59 PM, Percy Tambunan wrote: > Hai, I would like to parse this multiple root element XML Easy fix might be to wrap it in and , which will give you a new root. Would that help? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

parsing multiple root element XML into text

2014-05-09 Thread Percy Tambunan
Hai, I would like to parse this multiple root element XML 343741014 nu 343741015 nu into this create enumdnsched 4.1.0.1.4.7.3.4.3.2.6.e164.arpa -set naptrFlags=nu create enumdnsched 5.1.0.1.4.7.3.4.3.2.6.e164.arpa -set naptrFlags=nu Anyone can great