On Sat, 02 Feb 2008 07:24:36 +0100, Stefan Behnel wrote:
Steven D'Aprano wrote:
The same way it knows that ?xml is ?xml before it sees the
encoding. If the parser knows that the hex bytes
3c 3f 78 6d 6c
(or 3c 00 3f 00 78 00 6d 00 6c 00 if you prefer UTF-16, and feel free
to swap the
On Fri, 01 Feb 2008 07:51:56 +1100, Ben Finney wrote:
Steven D'Aprano [EMAIL PROTECTED] writes:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's
*not valid XML* if the XML declaration isn't immediately at the start
Steven D'Aprano wrote:
On Fri, 01 Feb 2008 07:51:56 +1100, Ben Finney wrote:
Steven D'Aprano [EMAIL PROTECTED] writes:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's
*not valid XML* if the XML declaration isn't
On Thu, 31 Jan 2008 18:35:17 +0100, Stefan Behnel wrote:
Hi,
Steven D'Aprano wrote:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of
the
Steven D'Aprano wrote:
The same way it knows that ?xml is ?xml before it sees the
encoding. If the parser knows that the hex bytes
3c 3f 78 6d 6c
(or 3c 00 3f 00 78 00 6d 00 6c 00 if you prefer UTF-16, and feel free to
swap the byte order)
mean ?xml
then it can equally know that
Ivan Illarionov wrote:
from xml.etree import ElementTree as et
from decimal import Decimal
root = et.parse('file/with/your.xml')
debits = dict((debit.attrib['category'],
Decimal(debit.find('amount').text)) for debit in root.findall('debit'))
for cat, amount in debits.items():
... print
Ricardo Aráoz schrieb:
Ivan Illarionov wrote:
from xml.etree import ElementTree as et
from decimal import Decimal
root = et.parse('file/with/your.xml')
debits = dict((debit.attrib['category'],
Decimal(debit.find('amount').text)) for debit in root.findall('debit'))
for cat, amount in
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Thanks Ivan, it seems a elegant API, and easy to use.
I tried to play a little with it but unfortunately could not get it off
the ground. I kept getting
root = et.fromstring(doc)
Traceback (most recent call last):
File input, line 1, in
Ricardo Aráoz schrieb:
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Thanks Ivan, it seems a elegant API, and easy to use.
I tried to play a little with it but unfortunately could not get it off
the ground. I kept getting
root = et.fromstring(doc)
Traceback (most recent call last):
File
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Thanks Ivan, it seems a elegant API, and easy to use.
I tried to play a little with it but unfortunately could not get it off
the ground. I kept getting
root = et.fromstring(doc)
Traceback (most
Steve Holden [EMAIL PROTECTED] writes:
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
doc =
?xml version=1.0?
It's not allowed to have a newline before the ?xml ...
Put it on the line above, and things will work.
If you don't think that looks pretty enough just escape the first
Ben Finney wrote:
Steve Holden [EMAIL PROTECTED] writes:
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
doc =
?xml version=1.0?
It's not allowed to have a newline before the ?xml ...
Put it on the line above, and things will work.
If you don't think that looks pretty enough just
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of the
document URL:http://www.w3.org/TR/xml/#sec-prolog-dtd. Many XML
parsers will (correctly) reject
Steven D'Aprano schrieb:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of the
document URL:http://www.w3.org/TR/xml/#sec-prolog-dtd. Many XML
Hi,
Steven D'Aprano wrote:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of the
document URL:http://www.w3.org/TR/xml/#sec-prolog-dtd. Many XML
Stefan Behnel wrote:
Steven D'Aprano wrote:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of the
document
Steven D'Aprano [EMAIL PROTECTED] writes:
On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
Quite apart from a human thinking it's pretty or not pretty, it's *not
valid XML* if the XML declaration isn't immediately at the start of the
document
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Diez B. Roggisch wrote:
Ricardo Aráoz schrieb:
Thanks Ivan, it seems a elegant API, and easy to use.
I tried to play a little with it but unfortunately could not get it off
the ground. I kept getting
root = et.fromstring(doc)
Traceback (most
Also, for XML documents, they were probably thinking that the
documents will be machine-generated most of the time. As far as I can
tell, they were right in that.
If anybody has to deal with human-generated XML/HTML in Python it may
be better to use something like
Ivan Illarionov wrote:
Also, for XML documents, they were probably thinking that the
documents will be machine-generated most of the time. As far as I can
tell, they were right in that.
If anybody has to deal with human-generated XML/HTML in Python it may
be better to use something like
from xml.etree import ElementTree as et
from decimal import Decimal
root = et.parse('file/with/your.xml')
debits = dict((debit.attrib['category'],
Decimal(debit.find('amount').text)) for debit in root.findall('debit'))
for cat, amount in debits.items():
... print '%s: %s' % (cat,
Ricardo Aráoz wrote:
What about :
doc =
moo
bar99/bar
/moo
foo
bar42/bar
/foo
That's not an XML document, so what about it?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Diez B. Roggisch wrote:
Simon Pickles schrieb:
Hi
Can anyone suggest a really simple XML reader for python? I just want to
be able to do something like this:
xmlDoc = xml.open(file.xml)
element = xmlDoc.GetElement(foo/bar)
... to read the value of:
foo
bar42/bar
/foo
Since
Hi,
Ricardo Aráoz wrote:
I don't know zit about xml, but I might need to, and I am saving the
thread for when I need it. So I looked around and found some 'real'
XML document (see below). The question is, how to access amounts from
debits (any category) but not deposits.
doc =
?xml
What about :
doc =
moo
bar99/bar
/moo
foo
bar42/bar
/foo
That's not an XML document, so what about it?
Stefan
--
Ok Stefan, I will pretend it was meant in good will.
I don't know zit about xml, but I might need to, and I am saving
Hi
Can anyone suggest a really simple XML reader for python? I just want to
be able to do something like this:
xmlDoc = xml.open(file.xml)
element = xmlDoc.GetElement(foo/bar)
... to read the value of:
foo
bar42/bar
/foo
Thanks
Simon
--
Linux user #458601 - http://counter.li.org
Simon Pickles schrieb:
Hi
Can anyone suggest a really simple XML reader for python? I just want to
be able to do something like this:
xmlDoc = xml.open(file.xml)
element = xmlDoc.GetElement(foo/bar)
... to read the value of:
foo
bar42/bar
/foo
Since python2.5, the ElementTree
Simon Pickles [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi
Can anyone suggest a really simple XML reader for python? I just want to
be able to do something like this:
xmlDoc = xml.open(file.xml)
element = xmlDoc.GetElement(foo/bar)
... to read the value of:
foo
check the implementation of XMLNode class here
http://hsivonen.iki.fi/group-feed/flickrapi.py
HTH
N
On Jan 27, 2008 11:05 PM, Simon Pickles [EMAIL PROTECTED] wrote:
Hi
Can anyone suggest a really simple XML reader for python? I just want to
be able to do something like this:
xmlDoc
29 matches
Mail list logo