Sambit Samal wrote:
> Hi ,
>
> Need help in Python Script using xml.etree.ElementTree to update the
> value of any element in below XML ( e.g SETNPI to be 5 ) based on some
> constraint ( e.g ) .
Something along the lines
from xml.etree import ElementTree as ET
tree =
On Friday, October 7, 2016 at 3:21:43 PM UTC-5, John Gordon wrote:
> root = doc.getroot()
> for child in root:
> print(child.tag)
>
Excellent! thank, you sir! that'll get me started.
Appreciate the reply.
Doug O'Leary
--
https://mail.python.org/mailman/listinfo/python-list
In <622ea3b0-88b4-420b-89e0-9e7c6e866...@googlegroups.com> Doug OLeary
writes:
> >>> from lxml import etree
> >>> doc =3D etree.parse('config.xml')
> Now what? For instance, how do I list the top level children of
> ?
root = doc.getroot()
for child in root:
Sepideh Ghanavati sepideh...@gmail.com writes:
I know basic of python and I have an xml file created from csv
What XML schema defines the document's format?
Without knowing the schema, parsing will be unreliable.
What created the document? Why is it relevant that the document was
“created
Sepideh Ghanavati schrieb am 06.04.2015 um 04:26:
I know basic of python and I have an xml file created from csv which has
three attributes category, definition and definition description.
I want to parse through xml file and identify actors, constraints,
principal from the text. However, I am
ming wrote:
Hi,
i've a Python script which stopped working about a month ago. But until
then, it worked flawlessly for months (if not years). A tiny
self-contained 7-line script is provided below.
i ran into an XML parsing problem with xml.dom.minidom and the error
message is included
On 2014-02-13 20:10, Peter Otten wrote:
ming wrote:
Hi,
i've a Python script which stopped working about a month ago. But until
then, it worked flawlessly for months (if not years). A tiny
self-contained 7-line script is provided below.
i ran into an XML parsing problem with
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
very
In i3c7lc$e6v$0...@news.t-online.com 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
inder wrote:
On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote:
Use the iterparse() function of the xml.etree.ElementTree package.
http://effbot.org/zone/element-iterparse.htm
http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk
Stefan
iterparse() is too big a hammer for
John Posner wrote:
Use the iterparse() function of the xml.etree.ElementTree package.
iterparse() is too big a hammer for this purpose, IMO. How about this:
from xml.etree.ElementTree import ElementTree
tree = ElementTree(None, myfile.xml)
for elem in tree.findall('//book/title'):
On Aug 18, 11:24 am, Stefan Behnel stefan...@behnel.de wrote:
inder wrote:
On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote:
Use the iterparse() function of the xml.etree.ElementTree package.
http://effbot.org/zone/element-iterparse.htm
inder wrote:
Is lxml part of standard python package ? I am having python 2.5 .
No, that's why I suggested ElementTree first.
I might not be able to use any additional package other than the
standard python . Could you please suggest something part of standard
python package ?
No, there
inder wrote:
I am new to xml . I need to parse the xml file . After reading and
browsing on the web , I could get much help .
I guess SAX would be better suited for my requirement .
That's a common misconception.
Could some juct provide me a sample python code so that I can execute
it
Use the iterparse() function of the xml.etree.ElementTree package.
http://effbot.org/zone/element-iterparse.htm
http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk
Stefan
iterparse() is too big a hammer for this purpose, IMO. How about this:
from xml.etree.ElementTree import
On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote:
Use the iterparse() function of the xml.etree.ElementTree package.
http://effbot.org/zone/element-iterparse.htm
http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk
Stefan
iterparse() is too big a hammer for this
-
From: hrishy [mailto:hris...@yahoo.co.uk]
Sent: Wednesday, February 25, 2009 11:36 PM
To: python-list@python.org; Paul McGuire
Subject: Re: XML Parsing
Ha the guru himself responding :-)
--- On Wed, 25/2/09, Paul McGuire pt...@austin.rr.com wrote:
From: Paul McGuire pt...@austin.rr.com
not use xpath to extract xml text from a xml doc ?
regards
Hrishy
--- On Wed, 25/2/09, Lie Ryan lie.1...@gmail.com wrote:
From: Lie Ryan lie.1...@gmail.com
Subject: Re: XML Parsing
To: python-list@python.org
Date: Wednesday, 25 February, 2009, 7:33 AM
Are you searching for answer or searching
xpath to extract xml text from a xml doc ?
regards
Hrishy
--- On Wed, 25/2/09, Lie Ryan lie.1...@gmail.com wrote:
From: Lie Ryan lie.1...@gmail.com
Subject: Re: XML Parsing
To: python-list@python.org
Date: Wednesday, 25 February, 2009, 7:33 AM
Are you searching for answer
On Feb 25, 1:17 am, hrishy hris...@yahoo.co.uk wrote:
Hi
Something like this
snip solution using ElementTree
Note i am not a python programmer just a enthusiast and i was curious why
people on the list didnt suggest a code like above
You just beat the rest of us to it - good example of
Ha the guru himself responding :-)
--- On Wed, 25/2/09, Paul McGuire pt...@austin.rr.com wrote:
From: Paul McGuire pt...@austin.rr.com
Subject: Re: XML Parsing
To: python-list@python.org
Date: Wednesday, 25 February, 2009, 2:04 PM
On Feb 25, 1:17 am, hrishy hris...@yahoo.co.uk
wrote:
Hi
Hi Cliff
Thanks so using elementree is the right way to handle this problem
regards
Hrishy
--- On Wed, 25/2/09, J. Clifford Dyer j...@sdf.lonestar.org wrote:
From: J. Clifford Dyer j...@sdf.lonestar.org
Subject: Re: XML Parsing
To: hris...@yahoo.co.uk
Cc: python-list@python.org, Lie Ryan
On Feb 25, 2:50 pm, Girish girish@gmail.com wrote:
Can anyone please tell me how to get content of Signal tag.. that
is, how to extract the data ![CDATA[Parameter Identifiers Supported -
$01 to $20]]
Was there something in particular about Jean-Paul Calderone's solution
that didn't satisfy
On Tue, 24 Feb 2009 20:50:20 -0800, Girish wrote:
Hello,
I have a xml file which is as follows:
pids
Parameter_Class
Parameter Id=pid_031605_093137_283
Identifier$/Identifier
TypePID/Type
:
From: Lie Ryan lie.1...@gmail.com
Subject: Re: XML Parsing
To: python-list@python.org
Date: Wednesday, 25 February, 2009, 5:43 AM
On Tue, 24 Feb 2009 20:50:20 -0800, Girish wrote:
Hello,
I have a xml file which is as follows:
pids
Parameter_Class
On Wed, 2009-02-25 at 06:09 +, hrishy wrote:
Hi
I am just a python enthusiast and not a python user but was just wundering
why didnt the list members come up with or recommen XPATH based solution
which i think is very elegant for this type of a problem isnt it ?
Did you mean XQuery?
Hi
Something like this
pids
Parameter_Class
ParameterId=pid_031605_093137_283
Identifier$/Identifier
TypePID/Type
Signal![CDATA[Parameter
Identifiers Supported - $01
to $20]]/Signal
Description![CDATA[This PID indicates which
Are you searching for answer or searching for another people that have
the same answer as you? :)
Many roads lead to Rome is a very famous quotation...
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari [EMAIL PROTECTED]
wrote:
Hello,
I am new to XML parsing.Could you kindly tell me whats the
problem with the following code:
import xml.dom.minidom
import xml.parsers.expat
document = token pos=nnLetterman/tokentoken pos=bezis/
Thanks ! it worked !
On Wed, Apr 2, 2008 at 1:31 AM, Konstantin Veretennicov
[EMAIL PROTECTED] wrote:
On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari [EMAIL PROTECTED]
wrote:
Hello,
I am new to XML parsing.Could you kindly tell me whats the
problem with the following code:
On Apr 1, 12:42 pm, Alok Kothari [EMAIL PROTECTED] wrote:
Hello,
I am new to XML parsing.Could you kindly tell me whats the
problem with the following code:
import xml.dom.minidom
import xml.parsers.expat
document = token pos=nnLetterman/tokentoken pos=bezis/
tokentoken
On Apr 1, 1:42 pm, Alok Kothari [EMAIL PROTECTED] wrote:
Hello,
I am new to XML parsing.Could you kindly tell me whats the
problem with the following code:
import xml.dom.minidom
import xml.parsers.expat
document = token pos=nnLetterman/tokentoken pos=bezis/
tokentoken
En Tue, 01 Apr 2008 20:44:41 -0300, 7stud [EMAIL PROTECTED]
escribió:
I am new to XML parsing.Could you kindly tell me whats the
problem with the following code:
import xml.dom.minidom
import xml.parsers.expat
I don't know if you are aware of the BeautifulSoup module:
Or
On 28 Mar 2007 00:38:38 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I want to parse this XML file:
?xml version=1.0 ?
text
text:one
filefilename/file
contents
Hello
/contents
/text:one
text:two
filefilename2/file
contents
Hello2
/contents
/text:two
/text
This XML will
[EMAIL PROTECTED] wrote:
I want to parse this XML file:
?xml version=1.0 ?
text
text:one
filefilename/file
contents
Hello
/contents
/text:one
text:two
filefilename2/file
contents
Hello2
/contents
/text:two
/text
This XML will be in a file called filecreate.xml
As
On Mar 28, 10:51 am, Diez B. Roggisch [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
I want to parse this XML file:
?xml version=1.0 ?
text
text:one
filefilename/file
contents
Hello
/contents
/text:one
text:two
filefilename2/file
contents
Hello2
/contents
[EMAIL PROTECTED] a écrit :
I want to parse this XML file:
zip
As you might have guessed, I want to create files from this XML file
contents, so how can I do this?
What modules should I use? What options do I have? Where can I find
tutorials? Will I be able to put
this on the internet (on a
[EMAIL PROTECTED] a écrit :
I want to parse this XML file:
?xml version=1.0 ?
text
text:one
filefilename/file
contents
Hello
/contents
/text:one
text:two
filefilename2/file
contents
Hello2
/contents
/text:two
/text
This XML will be in a file called filecreate.xml
As
The example is valid well-formed XML. It is permitted to use the :
character in element names. Whether one should in a non namespace
context is a different matter.
It is? I was always under the impression one has to declare a namespace. But
this might be shaped from the usage of XSLT and W3C
[EMAIL PROTECTED] wrote:
I want to parse this XML file:
?xml version=1.0 ?
text
text:one
filefilename/file
contents
Hello
/contents
/text:one
text:two
filefilename2/file
contents
Hello2
/contents
/text:two
/text
This XML will be in a file called filecreate.xml
As
HI,
I could suggest you to use the minidom xml parser from xml module. Your
XML schema does not seem to complocated. You will find detailed
descriptions, and working code in the book: Dive ino Python. Google for
it :-))
Gabor Urban
NMC - ART
--
c00i90wn wrote:
Stefan Behnel wrote:
c00i90wn wrote:
Hey, I'm having a problem with the xml.dom.minidom package, I want to
generate a simple xml for storing configuration variables, for that
purpose I've written the following code, but before pasting it I'll
tell you what my problem is. On
someone wrote:
Nice package ElementTree is but sadly it doesn't have a pretty print,
well, guess I'll have to do it myself, if you have one already can you
please give it to me? thanks :)
http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/indent.py
/F
--
c00i90wn wrote:
Nice package ElementTree is but sadly it doesn't have a pretty print,
well, guess I'll have to do it myself, if you have one already can you
please give it to me? thanks :)
FWIW Amara and plain old 4Suite both support pretty-print, canonical
XML print and more such options.
c00i90wn wrote:
On first write of the xml everything goes
as it should but on subsequent writes it starts to add more and more
unneeded newlines to it making it hard to read and ugly.
Pretty make it pretty by putting in newlines (and spaces) that are not
in the original data. That is, if you
c00i90wn wrote:
Hey, I'm having a problem with the xml.dom.minidom package, I want to
generate a simple xml for storing configuration variables, for that
purpose I've written the following code, but before pasting it I'll
tell you what my problem is. On first write of the xml everything goes
Nice package ElementTree is but sadly it doesn't have a pretty print,
well, guess I'll have to do it myself, if you have one already can you
please give it to me? thanks :)
Stefan Behnel wrote:
c00i90wn wrote:
Hey, I'm having a problem with the xml.dom.minidom package, I want to
generate a
Willem Ligtenberg wrote:
Is there an easy way, to couple data together. Because I have discoverd an
irritating feature in the xml file.
Sometimes this is a database reference:
Dbtag
Dbtag_dbUCSC/Dbtag_db
Dbtag_tag
Object-id
Willem Ligtenberg [EMAIL PROTECTED] wrote:
On Sun, 17 Apr 2005 02:16:04 +, William Park wrote:
Care to post more details?
The XML file I need to parse contains information about genes.
So the first element is a gene and then there are a lot sub-elements with
sub-elements. I only need
This is all the info I need from the xml file:
ID -- Gene-track_geneid320632/Gene-track_geneid
Name --Gene-ref
Gene-ref_locusPzp/Gene-ref_locus
Startbase -- Gene-commentary_seqs
Seq-loc
Seq-loc_int
Seq-interval
As I'm trying to write the code using cElementTree.
I stumble across one problem. Sometimes there are multiple values to
retrieve from one record for the same element. Like this:
Prot-ref_name_EATP-binding cassette, subfamily G, member 1/Prot-ref_name_E
Prot-ref_name_EATP-binding cassette
By the way, I know about findall, but when I iterate thruogh it like:
for x in function:
print 'function', x
I get:
function Element 'Prot-ref_name_E' at 0xb7d10cf8
function Element 'Prot-ref_name_E' at 0xb7d10d10
But ofcourse I want the information in there...
On Fri, 22 Apr 2005
Willem Ligtenberg wrote:
As I'm trying to write the code using cElementTree.
I stumble across one problem. Sometimes there are multiple values to
retrieve from one record for the same element. Like this:
Prot-ref_name_EATP-binding cassette, subfamily G, member 1/Prot-ref_name_E
As you can read in the other post of mine, my problem was with the
iterating through the list. didn't know that you should do. e.text. I did
only print e, not print e.text
Did read documentation, but must admit not everything.
Anyway, thank you very much!
On Fri, 22 Apr 2005 15:47:08 +0200,
Willem Ligtenberg wrote:
By the way, I know about findall, but when I iterate thruogh it like:
for x in function:
print 'function', x
I get:
function Element 'Prot-ref_name_E' at 0xb7d10cf8
function Element 'Prot-ref_name_E' at 0xb7d10d10
But ofcourse I want the information in there...
for x in
I'll first try it using SAX, because I want to have as little dependancies
as possible. I already have BioPython as a dependancy. And I personally
don't like to install lot's of packages for a program to work. So I don't
want to impose that on other people.
But thanks anyway and I might go for the
Sorry I just decided that I want to use your solution, but I am wondering
is cElemenTree in expat or is that something different?
On Wed, 20 Apr 2005
08:03:00 -0400, Kent Johnson wrote:
Willem Ligtenberg wrote:
Willem Ligtenberg [EMAIL PROTECTED] wrote:
I want to parse a very large (2.4 gig)
On 4/21/05, Willem Ligtenberg [EMAIL PROTECTED] wrote:
Sorry I just decided that I want to use your solution, but I am wondering
is cElemenTree in expat or is that something different?
Nope, cElemenTree is very much its own man. See
http://effbot.org/zone/celementtree.htm.
--
Cheers,
Simon
Don't assume that just because you have a 2.4G XML file that you have
2.4G of data. Looking at these verbose tags, plus the fact that the
XML is pretty-printed (all those leading spaces - not even tabs! - add
up), I'm guessing you only have about 5-10% actual data, and the rest
is just XML
On Sun, 17 Apr 2005 02:16:04 +, William Park wrote:
Willem Ligtenberg [EMAIL PROTECTED] wrote:
I want to parse a very large (2.4 gig) XML file (bioinformatics
ofcourse :)) But I have no clue how to do that. Most things I see read
the entire xml file at once. That isn't going to work here
Willem Ligtenberg wrote:
Willem Ligtenberg [EMAIL PROTECTED] wrote:
I want to parse a very large (2.4 gig) XML file (bioinformatics
ofcourse :)) But I have no clue how to do that. Most things I see read
the entire xml file at once. That isn't going to work here ofcourse.
So I would like to parse a
William Park wrote:
You may want to try Expat (www.libexpat.org) or Python wrapper to it.
Python comes with a low-level expat wrapper (pyexpat).
however, if you want performance, cElementTree (which also uses expat) is a
lot faster than pyexpat. (see my other post for links to benchmarks and
Willem Ligtenberg wrote:
I want to parse a very large (2.4 gig) XML file (bioinformatics ofcourse :))
But I have no clue how to do that. Most things I see read the entire xml
file at once. That isn't going to work here ofcourse.
So I would like to parse a XML file one record at a time and then be
Irmen de Jong wrote:
XML is not known for its efficiency
sarcasm Surely you are blaspheming, sir! XML's the greatest thing
since peanut butter! /sarcasm
I'm just *waiting* for the day someone finds its use on the rolls of
toilet paper... oh the glorious day...
--
Willem Ligtenberg wrote:
I want to parse a very large (2.4 gig) XML file (bioinformatics ofcourse :))
But I have no clue how to do that. Most things I see read the entire xml
file at once. That isn't going to work here ofcourse.
So I would like to parse a XML file one record at a time and then be
Kent Johnson wrote:
So I would like to parse a XML file one record at a time and then be able
to store the information in another object.
You might be interested in this recipe using ElementTree:
http://online.effbot.org/2004_12_01_archive.htm#element-generator
if you have ElementTree 1.2.5 or
Willem Ligtenberg [EMAIL PROTECTED] wrote:
I want to parse a very large (2.4 gig) XML file (bioinformatics
ofcourse :)) But I have no clue how to do that. Most things I see read
the entire xml file at once. That isn't going to work here ofcourse.
So I would like to parse a XML file one
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
~From your experience, do you think that if this wrong XML code could be
meant to be read only by somekind of Microsoft parser, the error will
not occur?
I'll try to explain:
xml producer writes the code in Windows platform and 'thinks' that every
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
~From your experience, do you think that if this wrong XML code could be
meant to be read only by somekind of Microsoft parser, the error will
not occur?
I'll try to explain:
xml producer writes the code in Windows platform and 'thinks' that every
Luis P. Mendes wrote:
xml producer writes the code in Windows platform and 'thinks' that every
client will read/parse the code with a specific Windows parser. Could
that (wrong) XML code parse correctly in that kind of specific Windows
client?
not if it's an XML parser.
Do you know any
Luis P. Mendes wrote:
From your experience, do you think that if this wrong XML code could be
meant to be read only by somekind of Microsoft parser, the error will
not occur?
This is very unlikely. MSXML would never do this incorrectly.
Regards,
Martin
--
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
this is the xml document:
?xml version=1.0 encoding=utf-8?
string xmlns=http://www..;lt;DataSetgt;
~ lt;Ordergt;
~ lt;Customergt;439lt;/Customergt;
(... others ...)
~ lt;/Ordergt;
lt;/DataSetgt;/string
When I do:
print
Luis P. Mendes wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
this is the xml document:
?xml version=1.0 encoding=utf-8?
string xmlns=http://www..;lt;DataSetgt;
~ lt;Ordergt;
~ lt;Customergt;439lt;/Customergt;
(... others ...)
~ lt;/Ordergt;
lt;/DataSetgt;/string
This is an
Kent Johnson wrote:
[...]
This is an XML document containing a single tag, string, whose content
is text containing entity-escaped XML.
This is *not* an XML document containing tags DataSet, Order,
Customer, etc.
All the behaviour you are seeing is a consequence of this. You need to
unescape
Irmen de Jong wrote:
Kent Johnson wrote:
[...]
This is an XML document containing a single tag, string, whose
content is text containing entity-escaped XML.
This is *not* an XML document containing tags DataSet, Order,
Customer, etc.
All the behaviour you are seeing is a consequence of this.
Luis P. Mendes wrote:
with:DataSetNode = stringNode.childNodes[0]
print DataSetNode.toxml()
I get:
lt;DataSetgt;
~ lt;Ordergt;
~lt;Customergt;439lt;/Customergt;
~ lt;/Ordergt;
lt;/DataSetgt;
___-
so far so good, but when I
Irmen de Jong wrote:
The unescaping is usually done for you by the xml parser that you use.
Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
lt; and gt;. The XML parser unescapes that as and . However, it
does not
Martin v. Löwis wrote:
Irmen de Jong wrote:
The unescaping is usually done for you by the xml parser that you use.
Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
lt; and gt;. The XML parser unescapes that as
Irmen de Jong wrote:
Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
lt; and gt;. The XML parser unescapes that as and . However, it
does not then consider the and as markup, and it shouldn't.
That's also what
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I would like to thank everyone for your answers, but I'm not seeing the
light yet!
When I access the url via the Firefox browser and look into the source
code, I also get:
?xml version=1.0 encoding=utf-8?
string xmlns=httplt;DataSetgt;
Luis P. Mendes wrote:
When I access the url via the Firefox browser and look into the source
code, I also get:
?xml version=1.0 encoding=utf-8?
string xmlns=httplt;DataSetgt;
~ lt;Ordergt;
~lt;Customergt;439lt;/Customergt;
~ lt;/Ordergt;
lt;/DataSetgt;/string
Please do try to
On Thu, 20 Jan 2005 21:54:30 +0100, Martin v. Lwis wrote:
Luis P. Mendes wrote:
When I access the url via the Firefox browser and look into the source
code, I also get:
?xml version=1.0 encoding=utf-8? string
xmlns=httplt;DataSetgt; ~ lt;Ordergt;
~
Luis P. Mendes wrote:
I get the following result:
?xml version=1.0 encoding=utf-8?
string xmlns=http://www..;lt;DataSetgt;
~ lt;Ordergt;
Most likely, this result is correct, and your document
really does contain
lt;Ordergt;
I don't get any elements. But, if I access the same url via a
83 matches
Mail list logo