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-

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

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

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

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

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 information) > > 1. here is m

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

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): >

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

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

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

Re: Parsing XML - Newbie help

2005-05-22 Thread Dan M
Hi rh0dium wrote: > I am relatively new to python and certainly new to XML parsing. Me too. However there are plenty of good docs/tutorials available to help with both XML and using it in Python. For XML you may wish to look at http://www.w3schools.com/. It has a very accessible set of tutor