Re: What library/package to use for parsing XML?

2017-01-31 Thread Chris Green
Irmen de Jong wrote: > On 30-1-2017 18:58, Chris Green wrote: > > I want to parse some XML data, it's the address book data from the > > linux program osmo. The file I want to parse is like this:- > > > > [snip] > > > > > I basically want to be able to extract the data and output in other > >

Re: What library/package to use for parsing XML?

2017-01-30 Thread Rob Gaddi
On 01/30/2017 02:14 PM, Juan C. wrote: On Mon, Jan 30, 2017 at 3:58 PM, Chris Green wrote: I want to parse some XML data, it's the address book data from the linux program osmo. The file I want to parse is like this:- Just like Irmen said, use the default xml.etree.ElementTree, it's amazing

Re: What library/package to use for parsing XML?

2017-01-30 Thread Juan C.
On Mon, Jan 30, 2017 at 3:58 PM, Chris Green wrote: > I want to parse some XML data, it's the address book data from the > linux program osmo. The file I want to parse is like this:- Just like Irmen said, use the default xml.etree.ElementTree, it's amazing and very simple to use. -- https://mai

Re: What library/package to use for parsing XML?

2017-01-30 Thread Irmen de Jong
On 30-1-2017 18:58, Chris Green wrote: > I want to parse some XML data, it's the address book data from the > linux program osmo. The file I want to parse is like this:- > [snip] > > I basically want to be able to extract the data and output in other > formats - e.g. write to a Sqlite3 databas

What library/package to use for parsing XML?

2017-01-30 Thread Chris Green
I want to parse some XML data, it's the address book data from the linux program osmo. The file I want to parse is like this:- None Peter and Denise Smith 0 0 Some address AAA BBB Oxfo

Re: encoding="utf8" ignored when parsing XML

2016-12-27 Thread Steve D'Aprano
On Wed, 28 Dec 2016 02:05 am, Skip Montanaro wrote: > I am trying to parse some XML which doesn't specify an encoding (Python > 2.7.12 via Anaconda on RH Linux), so it barfs when it encounters non-ASCII > data. No great surprise there, but I'm having trouble getting it to use > another encoding. F

Re: encoding="utf8" ignored when parsing XML

2016-12-27 Thread Peter Otten
Peter Otten wrote: > works, but to go back to the bytes that the XML parser needs the > "preferred encoding", in your case ASCII, will be used. Correction: it's probably sys.getdefaultencoding() rather than locale.getdefaultencoding(). So all systems with a sane configuration will behave the sa

Re: encoding="utf8" ignored when parsing XML

2016-12-27 Thread Peter Otten
Skip Montanaro wrote: > Peter> Isn't UTF-8 the default? > > Apparently not. Sorry, I meant the default for XML. > I believe in my reading it said that it used whatever > locale.getpreferredencoding() returned. That's problematic when you > live in a country that thinks ASCII is everything. Per

Re: encoding="utf8" ignored when parsing XML

2016-12-27 Thread Skip Montanaro
Peter> Isn't UTF-8 the default? Apparently not. I believe in my reading it said that it used whatever locale.getpreferredencoding() returned. That's problematic when you live in a country that thinks ASCII is everything. Personally, I think UTF-8 should be the default, but that train's long left t

Re: encoding="utf8" ignored when parsing XML

2016-12-27 Thread Peter Otten
Skip Montanaro wrote: > I am trying to parse some XML which doesn't specify an encoding (Python > 2.7.12 via Anaconda on RH Linux), so it barfs when it encounters non-ASCII > data. No great surprise there, but I'm having trouble getting it to use > another encoding. First, I tried specifying the e

encoding="utf8" ignored when parsing XML

2016-12-27 Thread Skip Montanaro
I am trying to parse some XML which doesn't specify an encoding (Python 2.7.12 via Anaconda on RH Linux), so it barfs when it encounters non-ASCII data. No great surprise there, but I'm having trouble getting it to use another encoding. First, I tried specifying the encoding when opening the fil

Re: Parsing XML Using XPATH for Python

2014-12-06 Thread Uzoma Ojemeni
On Tuesday, December 2, 2014 11:52:37 PM UTC+1, John Gordon wrote: > In Uzoma Ojemeni > writes: > > > I am new to Python - a few days old - and I would appreciate some help. > > > I want write a python code to parse the below XML as below:- > > > ServingCell--NeighbourCell > > L41_NBR

Re: Parsing XML Using XPATH for Python

2014-12-02 Thread dieter
Uzoma Ojemeni writes: ... One easy option would be to use the "XPath" support in the "lxml" package -- provided you have not problem with the installation of external libraries ("libxml2" and "libxslt") and C-extensions ("lxml"). -- https://mail.python.org/mailman/listinfo/python-list

Re: Parsing XML Using XPATH for Python

2014-12-02 Thread John Gordon
In Uzoma Ojemeni writes: > I am new to Python - a few days old - and I would appreciate some help. > I want write a python code to parse the below XML as below:- > ServingCell--NeighbourCell > L41_NBR3347_1--L41_NBR3347_2 > L41_NBR3347_1--L41_NBR3347_3 > L41_NBR3347_1-

Parsing XML Using XPATH for Python

2014-12-02 Thread Uzoma Ojemeni
I am new to Python - a few days old - and I would appreciate some help. I want write a python code to parse the below XML as below:- ServingCell--NeighbourCell L41_NBR3347_1--L41_NBR3347_2 L41_NBR3347_1--L41_NBR3347_3 L41_NBR3347_1--L41_NBR3349_1 L41_NBR3347_1-

Re: Parsing XML RSS feed byte stream for tag

2013-02-07 Thread xDog Walker
On Thursday 2013 February 07 12:36, darrel.rend...@gmail.com wrote: > As I've said, BeautifulSoup fails to find both pubDate and Link, which are > crucial to my app > Any advice would be greatly appreciated. http://packages.python.org/feedparser -- Yonder nor sorghum stenches shut ladle gulls st

Re: Parsing XML RSS feed byte stream for tag

2013-02-07 Thread John Gordon
In <16828a11-6c7c-4ab6-b406-6b8819883...@googlegroups.com> darrel.rend...@gmail.com writes: > def pageReader(url): > try: > readPage =3D urllib2.urlopen(url) > except urllib2.URLError, e: > # print 'We failed to reach a server.' > # print 'Reason: ', e.reason > return 404 =20 > except

Parsing XML RSS feed byte stream for tag

2013-02-07 Thread darrel . rendell
I'm attempting to parse an RSS feed for the first instance of an element "". def pageReader(url): try: readPage = urllib2.urlopen(url) except urllib2.URLError, e: # print 'We failed to reach a server.' # print 'Reason: ', e.reason return 404 except urllib2.HTTPError, e: # print('

Re: Python parsing XML file problem with SAX

2010-08-24 Thread Aahz
In article , Stefan Behnel wrote: >Christian Heimes, 10.08.2010 01:39: >> Am 10.08.2010 01:20, schrieb Aahz: >>> The docs say, "Parses an XML section into an element tree incrementally". >>> Sure sounds like it retains the entire parsed tree in RAM. Not good. >>> Again, how do you parse an XML f

Re: Python parsing XML file problem with SAX

2010-08-09 Thread Stefan Behnel
Christian Heimes, 10.08.2010 01:39: Am 10.08.2010 01:20, schrieb Aahz: The docs say, "Parses an XML section into an element tree incrementally". Sure sounds like it retains the entire parsed tree in RAM. Not good. Again, how do you parse an XML file larger than your available memory using somet

Re: Python parsing XML file problem with SAX

2010-08-09 Thread Christian Heimes
Am 10.08.2010 01:20, schrieb Aahz: > The docs say, "Parses an XML section into an element tree incrementally". > Sure sounds like it retains the entire parsed tree in RAM. Not good. > Again, how do you parse an XML file larger than your available memory > using something other than SAX? The docum

Re: Python parsing XML file problem with SAX

2010-08-09 Thread Aahz
In article , Stefan Behnel wrote: >Aahz, 09.08.2010 18:52: >> In article, >> Stefan Behnel wrote: >>> >>> First of all: don't use SAX. Use ElementTree's iterparse() function. That >>> will shrink you code down to a simple loop in a few lines. >> >> Unless I'm missing something, that only helps if

Re: Python parsing XML file problem with SAX

2010-08-09 Thread Stefan Behnel
Aahz, 09.08.2010 18:52: In article, Stefan Behnel wrote: First of all: don't use SAX. Use ElementTree's iterparse() function. That will shrink you code down to a simple loop in a few lines. Unless I'm missing something, that only helps if the final tree fits into memory. What do you suggest

Re: Python parsing XML file problem with SAX

2010-08-09 Thread Aahz
In article , Stefan Behnel wrote: > >First of all: don't use SAX. Use ElementTree's iterparse() function. That >will shrink you code down to a simple loop in a few lines. Unless I'm missing something, that only helps if the final tree fits into memory. What do you suggest other than SAX if you

Re: Python parsing XML file problem with SAX

2010-07-28 Thread Stefan Behnel
jia li, 28.07.2010 12:10: I have an XML file with hundreds of elements. What's strange is only one of there elements could not be parsed correctly: REVERSE_INULL Dispose_ParameterList Dispose_ParameterList UNINSPECTED 146 1/146MMSLib_LinkedList.c I printed the data in "characters(self, data)

Python parsing XML file problem with SAX

2010-07-28 Thread jia li
I have an XML file with hundreds of elements. What's strange is only one of there elements could not be parsed correctly: REVERSE_INULL Dispose_ParameterList Dispose_ParameterList UNINSPECTED 146 1/146MMSLib_LinkedList.c I printed the data in "characters(self, data)" and after parsing. The res

Re: parsing XML

2010-05-17 Thread kak...@gmail.com
On May 16, 10:52 am, Stefan Behnel wrote: > Jake b, 16.05.2010 09:40: > > > Check out Amara:http://www.xml3k.org/Amara/QuickRef > > > It looks promising. For a pythonic solution over sax / dom. > > > >>> Iter(doc.team.player) > > # or > > >>> doc.team.player[0].name > > Ah, right, and there's also

Re: parsing XML

2010-05-16 Thread Stefan Behnel
Jake b, 16.05.2010 09:40: Check out Amara: http://www.xml3k.org/Amara/QuickRef It looks promising. For a pythonic solution over sax / dom. >>> Iter(doc.team.player) # or >>> doc.team.player[0].name Ah, right, and there's also lxml.objectify: from lxml.objectify import parse root = p

Re: parsing XML

2010-05-16 Thread Jake b
2010 17:20:57 -0700 (PDT) > In-Reply-To: <4beec709$0$18653$4fafb...@reader3.news.tin.it> > References: > >         <4beec709$0$18653$4fafb...@reader3.news.tin.it> > Date: Sat, 15 May 2010 19:20:57 -0500 > Message-ID: > Subject: Re: parsing XML > From: Jake b

Re: parsing XML

2010-05-15 Thread Pietro Campesato
On May 14, 7:57 am, "kak...@gmail.com" wrote: > Hi to all, let's say we have the following Xml > >   >     17.1 >     6.4 >   >   >     15.5 >     7.8 >   > > > How can i get the players name, age and height? > DOM or SAX and how > > Thanks > Antonis I've found some code which converts an X

Re: parsing XML

2010-05-15 Thread superpollo
superpollo ha scritto: kak...@gmail.com ha scritto: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Thanks Antonis another minimal xml.etree.ElementTree solution: >>> print doc

Re: parsing XML

2010-05-15 Thread superpollo
kak...@gmail.com ha scritto: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Thanks Antonis another minimal xml.etree.ElementTree solution: >>> print document 17.1 6.

Re: parsing XML

2010-05-14 Thread Lawrence D'Oliveiro
In message , Stefan Behnel wrote: > Here's an overly complicated solution, but I thought that an object > oriented design would help here. How many times are you going to write the “"name", "age", "height"” sequence? The next assignment question I would ask is: how easy would it be to add a fo

Re: parsing XML

2010-05-14 Thread Martin v. Loewis
>>> Hi to all, let's say we have the following Xml >>> >>> >>> 17.1 >>> 6.4 >>> >>> >>> 15.5 >>> 7.8 >>> >>> >>> >>> How can i get the players name, age and height? >>> DOM or SAX and how >> >> Homework? > > I would hope that every school teacher who teaches P

Re: parsing XML

2010-05-14 Thread Adam Tauno Williams
On Fri, 2010-05-14 at 22:17 +0200, Stefan Behnel wrote: > >> > >> > >> 17.1 > >> 6.4 > >> > >> > >> 15.5 > >> 7.8 > >> > >> from lxml import etree handle = open('file', 'rb') doc = etree.parse(handle) handle.close() players = [ ] for player in doc.xpath('/tea

Re: parsing XML

2010-05-14 Thread Stefan Behnel
Martin v. Loewis, 14.05.2010 17:15: kak...@gmail.com wrote: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Homework? I would hope that every school teacher who teaches

Re: parsing XML

2010-05-14 Thread kak...@gmail.com
On May 14, 6:22 pm, Stefan Behnel wrote: > kak...@gmail.com, 14.05.2010 16:57: > > > Hi to all, let's say we have the following Xml > > > >     > >      17.1 > >      6.4 > >     > >     > >      15.5 > >      7.8 > >     > > > > > How can i get the players name, age and height? > > Here's an ov

Re: parsing XML

2010-05-14 Thread Stefan Behnel
kak...@gmail.com, 14.05.2010 16:57: Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? Here's an overly complicated solution, but I thought that an object oriented design would help here.

Re: parsing XML

2010-05-14 Thread Martin v. Loewis
kak...@gmail.com wrote: > Hi to all, let's say we have the following Xml > > > 17.1 > 6.4 > > > 15.5 > 7.8 > > > > How can i get the players name, age and height? > DOM or SAX and how Homework? Martin -- http://mail.python.org/mailman/listinfo/python-list

parsing XML

2010-05-14 Thread kak...@gmail.com
Hi to all, let's say we have the following Xml 17.1 6.4 15.5 7.8 How can i get the players name, age and height? DOM or SAX and how Thanks Antonis -- 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
On Fri, Jan 23, 2009 at 11:19 AM, aha wrote: > Hello All, > I've been charged with developing an XML configuration file format, > for one of the applications that my company develops. (Yes, I know it > would have been easier to just use the configuration file format as > described in RFC 822) W

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

2009-01-23 Thread aha
Hello All, I've been charged with developing an XML configuration file format, for one of the applications that my company develops. (Yes, I know it would have been easier to just use the configuration file format as described in RFC 822) While I am finally comfortable with the XML description

Re: BZip2 decompression and parsing XML

2008-06-06 Thread Stefan Behnel
phasma wrote: > xml.parsers.expat.ExpatError: not well-formed (invalid token): line > 538676, column 17 Looks like your XML file is broken in line 538676. > try: > handler = open(args[0], "r") This should read handler = open(args[0], "rb") Maybe t

BZip2 decompression and parsing XML

2008-06-06 Thread phasma
Hi. I'm trying to disassemble bzipped file. If I use minidom.parseString, I'm getting this error: Traceback (most recent call last): File "./replications.py", line 342, in ? File "/usr/lib64/python2.4/xml/dom/minidom.py", line 1925, in parseString return expatbuilder.parseString(string)

Re: Error in parsing XML for following test data

2008-01-29 Thread John Machin
On Jan 29, 9:29 pm, abhishek <[EMAIL PROTECTED]> wrote: > Hello group, > > I am having problem parsing following data set from XML. Please > provide hints on how to rectify this problem. You have provided no hints on what your problem is. What output do you want? What have you tried? What output a

Re: Error in parsing XML for following test data

2008-01-29 Thread Paul McGuire
On Jan 29, 4:46 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > > How is this related to XML? > > Stefan I guess that's what makes so **nasty**! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Error in parsing XML for following test data

2008-01-29 Thread Stefan Behnel
abhishek wrote: > I am having problem parsing following data set from XML. Please > provide hints on how to rectify this problem. > > I am using python2.4 version > > this is te test data that i am using -- > > """ > 1!!!11 > 2@@@22 > 3###33 > 4$$$

Error in parsing XML for following test data

2008-01-29 Thread abhishek
Hello group, I am having problem parsing following data set from XML. Please provide hints on how to rectify this problem. I am using python2.4 version this is te test data that i am using -- """ 1!!!11 2@@@22 3###33 4$$$44 5%%%5

Re: Parsing xml file in python

2007-10-30 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I am a newbie in python > I am trying to parse a xml file and write its content in a txt file. If you want to write code that does not hide your bugs behind cryptic event handlers and instead helps you get XML work done, try using ElementTree or lxml instead of SAX. The

Re: Parsing xml file in python

2007-10-30 Thread J. Clifford Dyer
On Tue, Oct 30, 2007 at 11:45:17AM -0700, [EMAIL PROTECTED] wrote regarding Re: Parsing xml file in python: Top-posting corrected > > > > On Oct 30, 12:32 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] schrieb: > > > >

Re: Parsing xml file in python

2007-10-30 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Oct 2007 11:45:17 -0700, amjadcsu wrote: > I am not getting into the xml parser. What does this mean!? > The error is not generated but also the /root/yhpc-2.0/ganglia.txt does > not contain anything. Maybe because… >> > def endElement(self,name): >> > if name=="HOST" an

Re: Parsing xml file in python

2007-10-30 Thread amjadcsu
That XML is just a snapshot I am not getting into the xml parser. The error is not generated but also the /root/yhpc-2.0/ganglia.txt does not contain anything. On Oct 30, 12:32 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > > > I am a newbie in python > > I

Re: Parsing xml file in python

2007-10-30 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > I am a newbie in python > I am trying to parse a xml file and write its content in a txt file. > The txt contains null elements. Any reason what iam doing wrong here > > > Here is the code that i wrote > > import sys,os > import xml.sax > import xml.sax.handler > fr

Parsing xml file in python

2007-10-30 Thread amjadcsu
I am a newbie in python I am trying to parse a xml file and write its content in a txt file. The txt contains null elements. Any reason what iam doing wrong here Here is the code that i wrote import sys,os import xml.sax import xml.sax.handler from xml.sax.handler import ContentHandler from xml

Re: ignoring chinese characters parsing xml file

2007-10-23 Thread Fabian López
Thanks, I have tried all you told me. It was an error on print statement. So I decided to catch the exception if I had an UnicodeEncodeError, that is, if I had chinese/japanese characters because they don't interest to me and it worked. The strip_asian function of Ryan didn't work well here, but it

Re: ignoring chinese characters parsing xml file

2007-10-23 Thread limodou
On 10/23/07, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Fabian López wrote: > > Thanks Mark, the code is like this. The attrib name is the problem: > > > > from lxml import etree > > > > context = etree.iterparse("file.xml") > > for action, elem in context: > > if elem.tag == "weblog": > >

Re: ignoring chinese characters parsing xml file

2007-10-23 Thread limodou
On 10/23/07, Fabian López <[EMAIL PROTECTED]> wrote: > Hi, > I am parsing an XML file that includes chineses characters, like > ^�u�u啖啖才是�w.���扉L锍才是�� or ヘアアイロン... The problem is that I get an error like: > UnicodeEncodeerror:'charmap' codec can't encode characters in position > The thing is th

Re: ignoring chinese characters parsing xml file

2007-10-22 Thread Stefan Behnel
Fabian López wrote: > Thanks Mark, the code is like this. The attrib name is the problem: > > from lxml import etree > > context = etree.iterparse("file.xml") > for action, elem in context: > if elem.tag == "weblog": > print action, elem.tag , elem.attrib["name"],elem.attrib["url"],

RE: ignoring chinese characters parsing xml file

2007-10-22 Thread Ryan Ginstrom
> On Behalf Of Fabian Lopez > like ^�u�u啖啖才是�w.���扉L锍才是�� or ヘアアイロン... The problem is that I get Just thought I'd point out here that the second string is Japanese, not Chinese. >From your second post, it appears that you've parsed the text without problems -- it's when you go to print them out

Re: ignoring chinese characters parsing xml file

2007-10-22 Thread Fabian López
Thanks Mark, the code is like this. The attrib name is the problem: from lxml import etree context = etree.iterparse("file.xml") for action, elem in context: if elem.tag == "weblog": print action, elem.tag , elem.attrib["name"],elem.attrib["url"], elem.attrib["rssUrl"] And the xml fi

Re: ignoring chinese characters parsing xml file

2007-10-22 Thread Marc 'BlackJack' Rintsch
On Mon, 22 Oct 2007 21:24:40 +0200, Fabian López wrote: > I am parsing an XML file that includes chineses characters, like ^ > uu啖啖才是w.扉L锍才是 or ヘアアイロン... The problem is that I get an error like: > UnicodeEncodeerror:'charmap' codec can't encode characters in > position.. You say you are *parsing*

ignoring chinese characters parsing xml file

2007-10-22 Thread Fabian López
Hi, I am parsing an XML file that includes chineses characters, like ^ �u�u啖啖才是�w.���扉L锍才是�� or ヘアアイロン... The problem is that I get an error like: UnicodeEncodeerror:'charmap' codec can't encode characters in position The thing is that I would like to ignore it and parse all the characters less

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread oren . tsur
On Jul 26, 4:34 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Jul 26, 3:13 pm, John Machin <[EMAIL PROTECTED]> wrote: > >> On Jul 26, 9:24 pm, [EMAIL PROTECTED] wrote: > > >>> OK, I solved the problem but I still don't get what went wrong. > >>> Solution - use tree

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > On Jul 26, 3:13 pm, John Machin <[EMAIL PROTECTED]> wrote: >> On Jul 26, 9:24 pm, [EMAIL PROTECTED] wrote: >> >>> OK, I solved the problem but I still don't get what went wrong. >>> Solution - use tree builder in order to create the new xml file >>> (previously I was "ma

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread oren . tsur
On Jul 26, 3:13 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 26, 9:24 pm, [EMAIL PROTECTED] wrote: > > > OK, I solved the problem but I still don't get what went wrong. > > Solution - use tree builder in order to create the new xml file > > (previously I was "manually" creating it). > > > I

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread John Machin
On Jul 26, 9:24 pm, [EMAIL PROTECTED] wrote: > OK, I solved the problem but I still don't get what went wrong. > Solution - use tree builder in order to create the new xml file > (previously I was "manually" creating it). > > I'm still curious so I'm adding a link to a short and very simple > scri

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread oren . tsur
OK, I solved the problem but I still don't get what went wrong. Solution - use tree builder in order to create the new xml file (previously I was "manually" creating it). I'm still curious so I'm adding a link to a short and very simple script that gets an xml (containing non ascii chars) from th

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: >> How about trying >> root = ElementTree.parse(urlopen(query), encoding ='utf-8') That doesn't work. > this specific thing is not working, however, parsing the url is not > problematic. So you tried parsing the complete XML file and it works? Then it's the way you stri

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread oren . tsur
> How about trying > root = ElementTree.parse(urlopen(query), encoding ='utf-8') > this specific thing is not working, however, parsing the url is not problematic. the problem is that after parsing the xml at the url I save some of the fields to a local file and the local file is not being parsed

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread André
On Jul 23, 11:29 am, [EMAIL PROTECTED] wrote: > (this question was also posted in the devshed python > forum:http://forums.devshed.com/python-programming-11/parsing-xml-with-elem... > ). > - > > (it's a bit longish but I hope I give all the info

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Steve Holden
Marc 'BlackJack' Rintsch wrote: > On Tue, 24 Jul 2007 05:57:26 +, oren.tsur wrote: > >> but the thing is that the parser parses it all right from the web (the >> amazon response) but fails to parse the locally saved file. > > I've just used wget to fetch that URL and `ElementTree` parses that

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Marc 'BlackJack' Rintsch
On Tue, 24 Jul 2007 05:57:26 +, oren.tsur wrote: > but the thing is that the parser parses it all right from the web (the > amazon response) but fails to parse the locally saved file. I've just used wget to fetch that URL and `ElementTree` parses that local file without problems. Maybe you s

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > On Jul 23, 4:46 pm, "Richard Brodie" <[EMAIL PROTECTED]> wrote: >> <[EMAIL PROTECTED]> wrote in message >> >> news:[EMAIL PROTECTED] >> >>> so what's the difference? how comes parsing is fine >>> in the first case but erroneous in the second case? >> You may have guessed

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-23 Thread oren . tsur
On Jul 23, 4:46 pm, "Richard Brodie" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > so what's the difference? how comes parsing is fine > > in the first case but erroneous in the second case? > > You may have guessed the encoding wrong. It probabl

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-23 Thread Richard Brodie
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > so what's the difference? how comes parsing is fine > in the first case but erroneous in the second case? You may have guessed the encoding wrong. It probably wasn't utf-8 to start with but iso8859-1 or similar. What actual byte valu

Parsing XML with ElementTree (unicode problem?)

2007-07-23 Thread oren . tsur
(this question was also posted in the devshed python forum: http://forums.devshed.com/python-programming-11/parsing-xml-with-elementtree-unicode-problem-461518.html ). - (it's a bit longish but I hope I give all the information) 1. here is my problem: I'm

Re: Help Parsing XML Namespaces with BeautifulSoup

2007-02-17 Thread Paul McGuire
On Feb 17, 6:55 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm trying to parse out some XML nodes with namespaces using > BeautifulSoup. I can't seem to get the syntax correct. It doesn't like > the colon in the tag name, and I'm not sure how to refer to that tag. > > I'm trying to get th

Help Parsing XML Namespaces with BeautifulSoup

2007-02-17 Thread [EMAIL PROTECTED]
I'm trying to parse out some XML nodes with namespaces using BeautifulSoup. I can't seem to get the syntax correct. It doesn't like the colon in the tag name, and I'm not sure how to refer to that tag. I'm trying to get the attributes of this tag: The only way I've been able to get it is by doi

FW: [Jython-users] ERROR : parsing xml in jython

2006-12-19 Thread Divya Prakash
Prakash Subject: Re: [Jython-users] ERROR : parsing xml in jython Hi, looks like you have to make an InputSource from the file, like so: from java.io import File, FileReader, StringReader textReader = FileReader(File(filename)) inputSource = InputSource(textReader) dp.parse(inputSource) Hope this

Re: Parsing XML using SAX

2006-10-23 Thread Fredrik Lundh
Nathan Harmston wrote: > However it is quite messy at the moment. The main reason is that Python > doesnt have a switch statement. a switch statement wouldn't save you a single line, so I find it a bit hard to believe that it's the main reason... > def startElement(self,name,attributes): >

Parsing XML using SAX

2006-10-23 Thread Nathan Harmston
Hi, Currently I m writing an XML parser that processes an xml file using sax, and I have it working, however I want to make the code of my parser less cluttered and more readable by other people (including myself). However it is quite messy at the moment. The main reason is that Python doesnt have

Re: Parsing XML/XSLT

2006-04-25 Thread Stefan Behnel
veracon wrote: > I'm looking to use XML and XSLT for templates in a system I'm writing, > however I'm not really sure which parser is the "best". Basically, > which library has the most features, and which is the most supported? lxml arguably has the most features by now, as it is based on libxml2

Re: Parsing XML/XSLT

2006-04-23 Thread Paul Boddie
veracon wrote: > > I'm looking to use XML and XSLT for templates in a system I'm writing, > however I'm not really sure which parser is the "best". Basically, > which library has the most features, and which is the most supported? I use (my own) libxml2dom [1] and XSLTools [2] to respectively pars

Parsing XML/XSLT

2006-04-23 Thread veracon
Hello, I'm looking to use XML and XSLT for templates in a system I'm writing, however I'm not really sure which parser is the "best". Basically, which library has the most features, and which is the most supported? A guide I saw mentioned importing xml.xslt, however it appears the xml module/pack

Re: Parsing XML scheme (xsd) to python objects

2006-02-10 Thread Bizarro-02
Yes, documents should also be validated against the schema. I finally managed to compile my schema with generateDS.py but I haven't tested the result because of my poor knowledge of Python. So I have to wait until the group does which wanted to use my schema. Thanks for your answer! Matthias --

Re: Parsing XML scheme (xsd) to python objects

2006-02-09 Thread Chris McDonough
You don't just want to parse the XSD data because there lots of XML parsers for Python. You want to validate documents against the schema, right? I haven't yet seen a good XML schema validator for Python. libxml2 has good bindings for validating XML against RelaxNG schemas. - C Bizarro-02 wr

Parsing XML scheme (xsd) to python objects

2006-02-09 Thread Bizarro-02
I have a XML scheme (xsd) from which I have created with xjc (a java binding compiler (JAXB)) my java objects with all the get and set methods. Now I have to use this scheme and do the same in python but I can't find a tool which can read the scheme. I already tried generateDS.py but it couldn't p

Re: error when parsing xml

2005-09-05 Thread Richard Brodie
> > I have found that some people refuse to stick to standards, so whenever I > > parse XML files I remove any characters that fall in the range > > <= 0x1f > > > >>= 0xf0 > > Now of what help shall that be? Get rid of all accented characters? > Sorry, but that surely is the dumbest thing to do he

Re: error when parsing xml

2005-09-05 Thread Diez B. Roggisch
> I have found that some people refuse to stick to standards, so whenever I > parse XML files I remove any characters that fall in the range > <= 0x1f > >>= 0xf0 Now of what help shall that be? Get rid of all accented characters? Sorry, but that surely is the dumbest thing to do here - and has

Re: error when parsing xml

2005-09-05 Thread Diez B. Roggisch
Odd-R. wrote: > This is retrieved through a webservice and stored in a variable test > > > > > ]> > æøå > > printing this out yields no problems, so the trouble seems to be when > executing > the following: > > doc = minidom.parseString(test) You need to do doc = minidom.parseString(test.e

Re: error when parsing xml

2005-09-05 Thread Fredrik Lundh
Odd-R. wrote: > This is retrieved through a webservice and stored in a variable test > > > > > ]> > æøå > > printing this out yields no problems, so the trouble seems to be when > executing < the following: > > doc = minidom.parseString(test) unless we have a cut-and-paste problem here, that

Re: error when parsing xml

2005-09-05 Thread Odd-R.
On 2005-09-05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Odd-R. wrote: > >> I use xml.dom.minidom to parse some xml, but when input >< contains some specific caracters(æ, ø and å), I get an >> UnicodeEncodeError, like this: >> >> UnicodeEncodeError: 'ascii' codec can't encode character >> u'\xe6'

error when parsing xml

2005-09-05 Thread Albert Leibbrandt
>> I use xml.dom.minidom to parse some xml, but when input >> contains some specific caracters(æ, ø and å), I get an >> UnicodeEncodeError, like this: >> >> UnicodeEncodeError: 'ascii' codec can't encode character >> u'\xe6' in position 604: ordinal not in range(128). >> >> How can I avoid this err

Re: error when parsing xml

2005-09-05 Thread Diez B. Roggisch
if you're getting this on the way in, something is broken (posting a short self-contained test program will help us figure out what's wrong). Or he tries to pass a unicode object to parseString. Regards, Diez # -*- coding: utf-8 -*- import xml.dom.minidom dom3 = xml.dom.minidom.parseString(

Re: error when parsing xml

2005-09-05 Thread Fredrik Lundh
Odd-R. wrote: > I use xml.dom.minidom to parse some xml, but when input < contains some specific caracters(æ, ø and å), I get an > UnicodeEncodeError, like this: > > UnicodeEncodeError: 'ascii' codec can't encode character > u'\xe6' in position 604: ordinal not in range(128). > > How can I avoid t

error when parsing xml

2005-09-05 Thread Odd-R.
I use xml.dom.minidom to parse some xml, but when input contains some specific caracters(æ, ø and å), I get an UnicodeEncodeError, like this: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in position 604: ordinal not in range(128). How can I avoid this error? All help much ap

Re: Parsing XML - Newbie help

2005-05-25 Thread Fredrik Lundh
"rh0dium" wrote: > Ok so up to here I am ok. I find ( If you want the full xml let me > know) two blocks of system memory. It MUST be "System Memory" only. > Now how do I get a list of all of the children "nodes" of this. They > are named bank:N ( i.e bank:0, bank:1 etc [see below] ). For eac

Re: Parsing XML - Newbie help

2005-05-22 Thread rh0dium
Fredrik Lundh wrote: > didn't you ask the same question a few days ago? did you read the > replies to that post? Yes I did but the XML was malformed.. Actually it still is but you helped me figure out a way to correct it - Thanks Here is what I have so far. Now I want to find a child of a chi

Re: Parsing XML - Newbie help

2005-05-22 Thread Fredrik Lundh
"rh0dium" wrote: > I am relatively new to python and certainly new to XML parsing. Can > some show me how to get the product text out of this? didn't you ask the same question a few days ago? did you read the replies to that post? assuming that your sample is correct, you need to process the a

  1   2   >