Re: lxml with python-3.12.0a5

2023-02-24 Thread Robin Becker
On 23/02/2023 18:09, Mats Wichmann wrote: I seem to always have trouble with lxml (which I know doesn't help). The cause would seem to be this: GH-101291: Refactor the `PyLongObject` struct into object header and PyLongValue struct. (GH-101292) So it looks to me like cython was

Re: lxml with python-3.12.0a5

2023-02-23 Thread Mats Wichmann
On 2/23/23 07:47, Mats Wichmann wrote: On 2/23/23 06:03, Robin Becker wrote: I'm trying to test python-3.12.0a5 and need to install lxml. My wheel build for lxml fails with errors like this src/lxml/etree.c: In function ‘__Pyx_PyIndex_AsSsize_t’: src/lxml/etree.c:270404:45: error: ‘PyLongObje

Re: lxml with python-3.12.0a5

2023-02-23 Thread Mats Wichmann
On 2/23/23 06:03, Robin Becker wrote: I'm trying to test python-3.12.0a5 and need to install lxml. My wheel build for lxml fails with errors like this src/lxml/etree.c: In function ‘__Pyx_PyIndex_AsSsize_t’: src/lxml/etree.c:270404:45: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no m

Re: lxml empty versus self closed tag

2022-03-03 Thread Dieter Maurer
Robin Becker wrote at 2022-3-3 09:21 +: >On 02/03/2022 18:39, Dieter Maurer wrote: >> Robin Becker wrote at 2022-3-2 15:32 +: >>> I'm using lxml.etree.XMLParser and would like to distinguish >>> >>> >>> >>> from >>> >>> >>> >>> I seem to have e.getchildren()==[] and e.text==None for both

Re: lxml empty versus self closed tag

2022-03-03 Thread Robin Becker
On 02/03/2022 18:39, Dieter Maurer wrote: Robin Becker wrote at 2022-3-2 15:32 +: I'm using lxml.etree.XMLParser and would like to distinguish from I seem to have e.getchildren()==[] and e.text==None for both cases. Is there a way to get the first to have e.text=='' I do not think s

Re: lxml empty versus self closed tag

2022-03-02 Thread Dieter Maurer
Robin Becker wrote at 2022-3-2 15:32 +: >I'm using lxml.etree.XMLParser and would like to distinguish > > > >from > > > >I seem to have e.getchildren()==[] and e.text==None for both cases. Is there a >way to get the first to have e.text=='' I do not think so (at least not without a DTD): `' i

Re: lxml parsing with validation and target?

2021-11-03 Thread Robin Becker
On 02/11/2021 12:55, Robin Becker wrote: I'm having a problem using lxml.etree to make a treebuilding parser that validates; I have test code where invalid xml is detected and an error raised when the line below target=ET.TreeBuilder(), is commented out. . I managed to overcome this p

Re: lxml - minor problem appending new element

2020-02-03 Thread Frank Millman
On 2020-02-03 10:39 AM, Peter Otten wrote: Frank Millman wrote: This is a minor issue, and I have found an ugly workaround, but I thought I would mention it. Like this? children = list(xml) for y in children: print(etree.tostring(y)) if y.get('z') == 'c': child = etree.Ele

Re: lxml - minor problem appending new element

2020-02-03 Thread Peter Otten
Frank Millman wrote: > Hi all > > I usually send lxml queries to the lxml mailing list, but it appears to > be not working, so I thought I would try here. > > This is a minor issue, and I have found an ugly workaround, but I > thought I would mention it. Like this? children = list(xml) for y i

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2019-12-03 Thread Karsten Hilbert
On Mon, Dec 02, 2019 at 08:58:11PM -0800, gerem...@gmail.com wrote: > Date: Mon, 2 Dec 2019 20:58:11 -0800 (PST) > From: gerem...@gmail.com > To: python-list@python.org > Subject: Re: lxml question -- creating an etree.Element attribute with ':' > in the name > User

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2019-12-03 Thread geremy85
Theanks a lot -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml namespace as an attribute

2018-08-17 Thread Stefan Behnel
Skip Montanaro schrieb am 15.08.2018 um 23:25: > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top level, then > adding namespaces=root.nsmap works when calling the xpath method. I > more-or-less get that. > > What I don

Re: lxml namespace as an attribute

2018-08-16 Thread Skip Montanaro
> You seem to think that you need to take the namespace definitions > from the XML document itself. This is not the case: you can > provide them from whatever soure you want. I was under the impression that XML was a self-describing format. I've been disabused of that notion. Skip -- https://mai

Re: lxml namespace as an attribute

2018-08-15 Thread dieter
Skip Montanaro writes: > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top level, then > adding namespaces=root.nsmap works when calling the xpath method. I > more-or-less get that. > > What I don't understand is how I'm

Re: lxml namespace as an attribute

2018-08-15 Thread Skip Montanaro
> See https://lxml.de/tutorial.html#namespaces and > https://lxml.de/2.1/FAQ.html#how-can-i-specify-a-default-namespace-for-xpath-expressions > for direction. I had read at least the namespaces section of the tutorial. I could see the namespace definition right there in the XML and figured somehow

RE: lxml namespace as an attribute

2018-08-15 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of Skip Montanaro Sent: Wednesday, August 15, 2018 3:26 PM To: Python Subject: lxml namespace as an attribute > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces are defined at the top

Re: lxml namespace as an attribute

2018-08-15 Thread Skip Montanaro
Ack. Of course I meant the subject to be "XML namespace as an attribute". I happen to be using lxml.etree. (Long day, I guess...) S On Wed, Aug 15, 2018 at 4:25 PM Skip Montanaro wrote: > > Much of XML makes no sense to me. Namespaces are one thing. If I'm > parsing a document where namespaces ar

Re: LXML: can't register namespace

2018-03-09 Thread Andrew Z
Stefan, thank you for the link. That explains the line of thinking of the package designer(s). I also looked@ beautifulsoup and found it to work better with my old brains. On Fri, Mar 9, 2018 at 9:46 AM, Stefan Behnel wrote: > Peter Otten schrieb am 09.03.2018 um 14:11: > > Stefan Behnel wrote:

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Peter Otten schrieb am 09.03.2018 um 14:11: > Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxml import etree >>> >>> tree = etree.parse('Sample.xml') >>> etree.register_namespace('','http://www.example.com') >> >

Re: LXML: can't register namespace

2018-03-09 Thread Peter Otten
Stefan Behnel wrote: > Andrew Z schrieb am 07.03.2018 um 05:03: >> Hello, >> with 3.6 and latest greatest lxml: >> >> from lxml import etree >> >> tree = etree.parse('Sample.xml') >> etree.register_namespace('','http://www.example.com') > > The default namespace prefix is spelled None (because

Re: LXML: can't register namespace

2018-03-09 Thread Steven D'Aprano
On Fri, 09 Mar 2018 13:08:10 +0100, Stefan Behnel wrote: >> Is there a good reason not to support "" as the empty prefix? > > Well, the "empty prefix" is not an "empty" prefix, it's *no* prefix. The > result is not ":tag" instead of "prefix:tag", the result is "tag". That makes sense, thanks.

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Steven D'Aprano schrieb am 09.03.2018 um 12:41: > On Fri, 09 Mar 2018 10:22:23 +0100, Stefan Behnel wrote: > >> Andrew Z schrieb am 07.03.2018 um 05:03: >>> Hello, >>> with 3.6 and latest greatest lxml: >>> >>> from lxml import etree >>> >>> tree = etree.parse('Sample.xml') >>> etree.register_nam

Re: LXML: can't register namespace

2018-03-09 Thread Steven D'Aprano
On Fri, 09 Mar 2018 10:22:23 +0100, Stefan Behnel wrote: > Andrew Z schrieb am 07.03.2018 um 05:03: >> Hello, >> with 3.6 and latest greatest lxml: >> >> from lxml import etree >> >> tree = etree.parse('Sample.xml') >> etree.register_namespace('','http://www.example.com') > > The default names

Re: LXML: can't register namespace

2018-03-09 Thread Stefan Behnel
Andrew Z schrieb am 07.03.2018 um 05:03: > Hello, > with 3.6 and latest greatest lxml: > > from lxml import etree > > tree = etree.parse('Sample.xml') > etree.register_namespace('','http://www.example.com') The default namespace prefix is spelled None (because there is no prefix for it) and not

Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
help(etree.register_namespace) Help on cython_function_or_method in module lxml.etree: register_namespace(prefix, uri) Registers a namespace prefix that newly created Elements in that namespace will use. The registry is global, and any existing mapping for either the given prefix or th

Re: LXML: can't register namespace

2018-03-07 Thread Andrew Z
Yes, if i give it any non empty tag - all goes well. All im trying to do is to extract a namespace ( i try to keep simple here. Just first one for now) and register it so i can save xml later on. On Mar 7, 2018 00:38, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > On Tue, 06

Re: LXML: can't register namespace

2018-03-06 Thread Steven D'Aprano
On Tue, 06 Mar 2018 23:03:15 -0500, Andrew Z wrote: > Hello, > with 3.6 and latest greatest lxml: > > from lxml import etree > > tree = etree.parse('Sample.xml') > etree.register_namespace('','http://www.example.com') > it seems to not be happy with the empty tag . But i'm not sure why and > h

Re: lxml and xpath(?)

2016-11-02 Thread dieter
Doug OLeary writes: > ... > Any hints/tips/suggestions greatly appreciated especially with complete noob > tutorials for xpath. You can certainly do it with "XPath" (look for the "following-sibling" axis). You can also use Python (with "lxml"). If you have an element "e", then "e.getnext()" giv

Re: lxml and xpath(?)

2016-10-27 Thread Peter Otten
Pete Forman wrote: > Peter Otten <__pete...@web.de> writes: > >> root = etree.fromstring(s) >> for server in root.xpath("./server"): >> servername = server.xpath("./name/text()")[0] > > When working with lxml I prefer to use this Python idiom. > > servername, = server.xpath("./name/text

Re: lxml and xpath(?)

2016-10-27 Thread Pete Forman
Peter Otten <__pete...@web.de> writes: > root = etree.fromstring(s) > for server in root.xpath("./server"): > servername = server.xpath("./name/text()")[0] When working with lxml I prefer to use this Python idiom. servername, = server.xpath("./name/text()") That enforces a single result

Re: lxml and xpath(?)

2016-10-26 Thread Peter Otten
Doug OLeary wrote: > Hey; > > Reasonably new to python and incredibly new to xml much less trying to > parse it. I need to identify cluster nodes from a series of weblogic xml > configuration files. I've figured out how to get 75% of them; now, I'm > going after the edge case and I'm unsure how t

Re: lxml ignore none in getchildren

2016-10-04 Thread Peter Otten
Sayth Renshaw wrote: > I am following John Shipmans example from > http://infohost.nmt.edu/~shipman/soft/pylxml/web/Element-getchildren.html > xml = ''' > ... ''' pen = etree.fromstring(xml) penContents = pen.getchildren() for content in penContents: > ... print "%-10s %

Re: lxml - SubElement dump root doesn't dump like Element dump does

2016-06-20 Thread Sayth Renshaw
On Monday, 20 June 2016 16:19:31 UTC+10, Peter Otten wrote: > Sayth Renshaw wrote: > > > Afternoon > > > > Wondering has anyone much experience with lxml specifically objectify? > > > > When I pick up a file with lxml and use objectify dumping root works as > > expected actually better its quit

Re: lxml - SubElement dump root doesn't dump like Element dump does

2016-06-20 Thread Sayth Renshaw
Thanks your way makes more sense indeed. In the example they create and access I think I just got lost in their example. Sayth -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml - SubElement dump root doesn't dump like Element dump does

2016-06-19 Thread Peter Otten
Sayth Renshaw wrote: > Afternoon > > Wondering has anyone much experience with lxml specifically objectify? > > When I pick up a file with lxml and use objectify dumping root works as > expected actually better its quite nice. This is how i do it, file > handling part left out for brevity. > >

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Sayth Renshaw
Awesome, thanks so much for the help. Sayth -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Stefan Behnel
Sayth Renshaw schrieb am 08.02.2015 um 12:22: > How can I actually access the values of an element with lxml objectify? > > for example if I had this element in my xml file. > > VenueCode="151" TrackName="Main" TrackCode="149"> > > I can see all the attributes using this. > > In [86]: for chil

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Kev Dwyer
Sayth Renshaw wrote: > > Hi > > How can I actually access the values of an element with lxml objectify? > > for example if I had this element in my xml file. > > VenueCode="151" TrackName="Main" TrackCode="149"> > > I can see all the attributes using this. > > In [86]: for child in root.get

Re: lxml and namespaces

2014-07-29 Thread Irmen de Jong
On 29-7-2014 20:35, Marc Aymerich wrote: > Got it! > xml = lxml.builder.ElementMaker( > nsmap = { > None: "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02", > 'xsi': "http://www.w3.org/2001/XMLSchema-instance";, > } > ) > doc = xml.Document() Thanks for taking the tim

Re: lxml and namespaces

2014-07-29 Thread Marc Aymerich
On Tue, Jul 29, 2014 at 8:19 PM, Marc Aymerich wrote: > Hi, I'm desperately trying to construct an XML with the following document > declaration: > > xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”> > > I'm using LXML, and what I'm doing is this > > >>> from lxml import etree > >>>

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-19 Thread Stefan Behnel
Burak Arslan, 18.09.2013 21:35: > On 09/18/13 21:59, Roy Smith wrote: >> I can create an Element with a 'foo' attribute by doing: >> >> etree.Element('my_node_name', foo="spam") >> >> But, how do I handle something like: >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-18 Thread dieter
Roy Smith writes: > But, how do I handle something like: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi" > isn't a valid python identifier? Read about "lxml"'s "namespace" support. -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-18 Thread Burak Arslan
On 09/18/13 21:59, Roy Smith wrote: > I can create an Element with a 'foo' attribute by doing: > > etree.Element('my_node_name', foo="spam") > > But, how do I handle something like: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi" > isn't a valid python identifier? > >

Re: lxml question -- creating an etree.Element attribute with ':' in the name

2013-09-18 Thread Zachary Ware
On Wed, Sep 18, 2013 at 1:59 PM, Roy Smith wrote: > I can create an Element with a 'foo' attribute by doing: > > etree.Element('my_node_name', foo="spam") > > But, how do I handle something like: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";, since "xmlns:xsi" > isn't a valid python

Re: lxml tostring quoting too much

2013-08-07 Thread andrea crotti
2013/8/6 Chris Down : > On 2013-08-06 18:38, andrea crotti wrote: >> I would really like to do the following: >> >> from lxml import etree as ET >> from lxml.builder import E >> >> url = "http://something?x=10&y=20"; >> l = E.link(url) >> ET.tostring(l) -> "http://something?x=10&y=20" >> >> However

Re: lxml tostring quoting too much

2013-08-06 Thread Chris Down
On 2013-08-06 18:38, andrea crotti wrote: > I would really like to do the following: > > from lxml import etree as ET > from lxml.builder import E > > url = "http://something?x=10&y=20"; > l = E.link(url) > ET.tostring(l) -> "http://something?x=10&y=20" > > However the lxml tostring always quotes t

Re: lxml 3.0 final released - efficient XML and HTML processing with Python

2012-10-10 Thread D.M. Procida
Stefan Behnel wrote: > it's been a while since the last stable release series appeared, so I'm > proud to announce the final release of lxml 3.0. Great. We use it in . Thanks. Daniele -- http://mail.python.org/mailman/listinfo/python

Re: lxml can't output right unicode result

2012-09-06 Thread MRAB
On 07/09/2012 01:21, contro opinion wrote: i eidt a file and save it in gbk encode named test. my system is :debian,locale,en.utf-8;python2.6,locale,utf-8. 你 in terminal i input: xxd test 000: 3c68 746d 6c3e 0a3c 703e c4e3 3c2f 703e ... 010: 0a3c 2f68 746d 6c3e 0a

Re: lxml to parse html

2012-01-23 Thread Adam Tauno Williams
On Mon, 2012-01-23 at 15:39 +0800, contro opinion wrote: > import lxml.html > myxml=''' > > > Use lxml.etree not lxml.html. Your content is XML, not HTML. -- System & Network Administrator [ LPI & NCLA ] OpenGroupware Developer

Re: lxml to parse html

2012-01-23 Thread Stefan Behnel
contro opinion, 23.01.2012 08:34: > import lxml.html > myxml=''' > > > > > table="tpa_radio_sum"> > > > > > > > ''' > root=lxml.html.fromstring(myxml) > nodes1=root.xpath('//job[@DecreaseHour="1"]') > nodes2=

Re: lxml to parse html

2012-01-23 Thread Peter Otten
contro opinion wrote: > import lxml.html > myxml=''' > > > > > > > > > > > > ''' > root=lxml.html.fromstring(myxml) > nodes1=root.xpath('//job[@DecreaseHour="1"]') > nodes2=root.xpath('//job[@table="tpa_radio_sum"]') > print "nodes1=",nodes1 > print "nodes2=",nodes2 > > > nodes1=

Re: lxml precaching DTD for document verification.

2011-11-28 Thread Gelonida N
Thanks Stefan, On 11/28/2011 08:38 AM, Stefan Behnel wrote: > Gelonida N, 27.11.2011 18:57: >> I'd like to verify some (x)html / / html5 / xml documents from a server. >> >> These documents have a very limited number of different doc types / DTDs. >> >> So what I would like to do is to build a sm

Re: lxml precaching DTD for document verification.

2011-11-27 Thread Stefan Behnel
Gelonida N, 27.11.2011 18:57: I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and o

Re: lxml precaching DTD for document verification.

2011-11-27 Thread Gelonida N
On 11/27/2011 10:33 PM, John Gordon wrote: > In Roy Smith > writes: > >> In article , >> Gelonida N wrote: >> >>> I'd like to verify some (x)html / / html5 / xml documents from a server. > >> I'm sure you could roll your own validator with lxml and some DTDs, but >> you would probably sav

Re: lxml precaching DTD for document verification.

2011-11-27 Thread John Gordon
In Roy Smith writes: > In article , > Gelonida N wrote: > > > I'd like to verify some (x)html / / html5 / xml documents from a server. > I'm sure you could roll your own validator with lxml and some DTDs, but > you would probably save yourself a huge amount of effort by just using > the v

Re: lxml precaching DTD for document verification.

2011-11-27 Thread Roy Smith
In article , Gelonida N wrote: > I'd like to verify some (x)html / / html5 / xml documents from a server. I'm sure you could roll your own validator with lxml and some DTDs, but you would probably save yourself a huge amount of effort by just using the validator the W3C provides (http://vali

Re: lxml

2011-02-25 Thread Colin J. Williams
On 24-Feb-11 19:39 PM, alex23 wrote: On Feb 24, 6:20 pm, Stefan Behnel wrote: MRAB, 24.02.2011 01:25: The latest stable release is here: http://pypi.python.org/pypi/lxml/2.2.8 Not quite the latest "stable release" (that would be 2.3), but at least one that's pre-built for Windows. Chris

Re: lxml

2011-02-24 Thread alex23
On Feb 24, 6:20 pm, Stefan Behnel wrote: > MRAB, 24.02.2011 01:25: > > The latest stable release is here: > > >http://pypi.python.org/pypi/lxml/2.2.8 > > Not quite the latest "stable release" (that would be 2.3), but at least one > that's pre-built for Windows. Christoph Gohlke has an 'unofficial

Re: lxml

2011-02-24 Thread Colin J. Williams
On 24-Feb-11 03:20 AM, Stefan Behnel wrote: MRAB, 24.02.2011 01:25: On 24/02/2011 00:10, Colin J. Williams wrote: Could someone please let me know whether lxml is available for Windows XP?. If so, is it available for Python 2.7? The latest stable release is here: http://pypi.python.org/pypi/

Re: lxml

2011-02-24 Thread Stefan Behnel
MRAB, 24.02.2011 01:25: On 24/02/2011 00:10, Colin J. Williams wrote: Could someone please let me know whether lxml is available for Windows XP?. If so, is it available for Python 2.7? The latest stable release is here: http://pypi.python.org/pypi/lxml/2.2.8 Not quite the latest "stable rel

Re: lxml

2011-02-23 Thread MRAB
On 24/02/2011 00:10, Colin J. Williams wrote: Could someone please let me know whether lxml is available for Windows XP?. If so, is it available for Python 2.7? The latest stable release is here: http://pypi.python.org/pypi/lxml/2.2.8 -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml etree question

2010-12-26 Thread Stefan Behnel
Jim, 26.12.2010 00:32: On Dec 25, 5:33 am, Stefan Behnel wrote: lxml knows about this special case, so you can write {http://www.w3.org/XML/1998/namespace}lang and lxml will take care of using the right prefix. Stefan, thank you for the software, which has helped me a great deal. I

Re: lxml etree question

2010-12-26 Thread Carl Banks
On Dec 24, 10:17 am, Adam Tauno Williams wrote: > On Fri, 2010-12-24 at 20:48 +0530, Nitin Pawar wrote: > > On Fri, Dec 24, 2010 at 8:40 PM, Jim wrote: > >         Hello,  I wonder if someone knows about lxml.etree and > >         namespaces? > > Yes, and don't. He's using lxml.etree (which is a

Re: lxml etree question

2010-12-25 Thread Jim
On Dec 25, 5:33 am, Stefan Behnel wrote: > lxml knows about this special case, so you can write > >         {http://www.w3.org/XML/1998/namespace}lang > > and lxml will take care of using the right prefix. Stefan, thank you for the software, which has helped me a great deal. I tried that exact t

Re: lxml etree question

2010-12-25 Thread Stefan Behnel
Jim, 24.12.2010 16:10: Hello, I wonder if someone knows about lxml.etree and namespaces? I want to build an ElementTree where some of the sub-elements have attributes that serialize this way. .. I've tried just comment_elet.set('xml:lang','de') and it didn't like that at all (although it t

Re: lxml etree question

2010-12-24 Thread Adam Tauno Williams
On Fri, 2010-12-24 at 20:48 +0530, Nitin Pawar wrote: > On Fri, Dec 24, 2010 at 8:40 PM, Jim wrote: > Hello, I wonder if someone knows about lxml.etree and > namespaces? Yes, and don't. > I want to build an ElementTree where some of the sub-elements have > attributes that serial

Re: lxml etree question

2010-12-24 Thread Nitin Pawar
On Fri, Dec 24, 2010 at 8:40 PM, Jim wrote: > Hello, I wonder if someone knows about lxml.etree and namespaces? > > I want to build an ElementTree where some of the sub-elements have > attributes that serialize this way. > > .. > > I've tried just comment_elet.set('xml:lang','de') and it didn't

RE: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread VYAS ASHISH M-NTB837
o: VYAS ASHISH M-NTB837 Cc: python-list@python.org Subject: Re: lxml 2.2.4 on python3.1, Windows XP gives importerror On 1/5/2010 1:38 AM, VYAS ASHISH M-NTB837 wrote: > Dear All > I have Python 3.1 installed on Windows XP and Works nice. > I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py

Re: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread Sridhar Ratnakumar
On 1/5/2010 1:38 AM, VYAS ASHISH M-NTB837 wrote: Dear All I have Python 3.1 installed on Windows XP and Works nice. I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi. When I try: from lxml import etree I get: ImportError: DLL load failed: This application has failed to start because

RE: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread VYAS ASHISH M-NTB837
Posting again as I did not get any response: Dear All I have Python 3.1 installed on Windows XP and Works nice. I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi. When I try: from lxml import etree I get: ImportError: DLL load failed: This application has failed to start because

Re: lxml 2.2.4 for Python 2.6

2009-11-24 Thread Sérgio Monteiro Basto
Hi, Srijit Kumar Bhadra wrote: > Is there any reason why lxml-2.2.4-py2.6-win32.egg (md5) or > lxml-2.2.4.win32-py2.6.exe is not available? > > Best regards, > /Srijit maybe ask on lxml Mailing List , should be more appropriated Sérgio M. B. -- http://mail.python.org/mailman/listinfo/python

Re: lxml and xmlsec

2009-09-28 Thread Stefan Behnel
Roland Hedberg wrote: > Anyone know if it is possible to use xmlsec together with lxml ? I remember reading on the lxml mailing list that someone uses both together. You might want to ask over there. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml question

2009-09-10 Thread Diez B. Roggisch
mattia wrote: > I would like to click on an image in a web page that I retrieve using > urllib in order to trigger an event. > Here is the piece of code with the image that I want to click: > onclick="return checkPhoneField(document.contactFrm, 'mobile');" > alt="sms" src="images/button_sms.bmp"

Re: lxml question

2009-09-09 Thread Chris Rebert
On Wed, Sep 9, 2009 at 4:11 PM, mattia wrote: > I would like to click on an image in a web page that I retrieve using > urllib in order to trigger an event. > Here is the piece of code with the image that I want to click: > onclick="return checkPhoneField(document.contactFrm, 'mobile');" > alt="sm

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-30 Thread Stefan Behnel
byron wrote: > I am using the lxml.etree library to validate an xml instance file > with a specified schema that contains the data types of each element. > This is some of the internals of a function that extracts the > elements: > > schema_doc = etree.parse(schema_fn) > schema = e

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-21 Thread byron
On May 21, 8:27 pm, MRAB wrote: > byron wrote: > > [snip] > > > Thanks. Yes i tried something like this, but I think I overwrite `c` > > when i wrote it, as in: > > >     if len(c) > 0: > >         c = fin_node(c, name) > >         if c is not None: > >             return c > > FYI, doing that won

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-21 Thread MRAB
byron wrote: [snip] Thanks. Yes i tried something like this, but I think I overwrite `c` when i wrote it, as in: if len(c) > 0: c = fin_node(c, name) if c is not None: return c FYI, doing that won't actually matter in this case; 'c' will still be bound to the n

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-21 Thread byron
On May 21, 6:57 pm, MRAB wrote: > byron wrote: > > I am using the lxml.etree library to validate an xml instance file > > with a specified schema that contains the data types of each element. > > This is some of the internals of a function that extracts the > > elements: > > >         schema_doc =

Re: lxml: traverse xml tree and retrieve element based on an attribute

2009-05-21 Thread MRAB
byron wrote: I am using the lxml.etree library to validate an xml instance file with a specified schema that contains the data types of each element. This is some of the internals of a function that extracts the elements: schema_doc = etree.parse(schema_fn) schema = etree.XMLSche

Re: lxml and xslt extensions

2009-04-04 Thread Stefan Behnel
Hi, dasacc22 wrote: > On Apr 4, 11:31 am, dasacc22 wrote: >> Im not sure where else to ask this. The best place to ask is the lxml mailing list: http://codespeak.net/mailman/listinfo/lxml-dev >> But basically Im having trouble >> figuring out how to successfully apply multiple extensions in a

Re: lxml and xslt extensions

2009-04-04 Thread dasacc22
On Apr 4, 11:31 am, dasacc22 wrote: > Hi, > > Im not sure where else to ask this. But basically Im having trouble > figuring out how to successfully apply multiple extensions in a single > transformation. So for example if i have > > > > > > > > in my xsl and my xslt extension looks like > >

Re: lxml removing tag, keeping text order

2008-10-27 Thread Tim Arnold
"Stefan Behnel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Tim Arnold schrieb: >> Hi, >> Using lxml to clean up auto-generated xml to validate against a dtd; I >> need >> to remove an element tag but keep the text in order. For example >> s0 = ''' >> >>first text >> la

Re: lxml removing tag, keeping text order

2008-10-25 Thread Stefan Behnel
Tim Arnold schrieb: > Hi, > Using lxml to clean up auto-generated xml to validate against a dtd; I need > to remove an element tag but keep the text in order. For example > s0 = ''' > >first text > ladida > emphasized text > middle text > > last text > > ''' > > I wan

Re: lxml question

2008-10-03 Thread Stefan Behnel
Uwe Schmitt wrote: > I have to parse some text which pretends to be XML. lxml does not want > to parse it, because it lacks a root element. > I think that this situation is not unusual, so: is there a way to > force lxml to parse it ? > > My work around is wrapping the text with "..." before > fee

Re: lxml and adding a stylesheet

2008-10-03 Thread Stefan Behnel
Sean Davis wrote: > I have an xml document and simply need to add an xml-stylesheet to > it. I am using lxml to parse the xml document and then would like to > insert the xml-stylesheet tag using the etree api. Any suggestions? I assume you are talking about a processing instruction here, not a

Re: lxml and schema validation

2008-10-03 Thread Stefan Behnel
hrishy wrote: > I am validating a xmlfile against a xsd (My.xsd) but i notice that the xsd > has a include which includes another xsd (My1.xsd) > > I have written a simple program that to validate this > > from lxml import etree > xmlschemadoc=etree.parse("My.xsd") > xmlschema=etree.XMLSchema(xm

Re: lxml question

2008-09-26 Thread alex23
On Sep 27, 1:19 am, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > I have to parse some text which pretends to be XML. lxml does not want > to parse it, because it lacks a root element. Another option is BeautifulSoup, which handles badly formed XML really well: http://www.crummy.com/software/Beautiful

Re: lxml question

2008-09-26 Thread Mark Thomas
On Sep 26, 11:19 am, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > I have to parse some text which pretends to be XML. lxml does not want > to parse it, because it lacks a root element. > I think that this situation is not unusual, so: is there a way to > force lxml to parse it ? By "pretends to be XML

Re: lxml build error in sun

2008-09-13 Thread Stefan Behnel
Owen Zhang wrote: > I am trying to build lxml package in SunOS 5.10. I got the following > errors. Could you report this on the lxml mailing list? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml, comparing nodes

2008-07-25 Thread Stefan Behnel
code_berzerker wrote: >> Not in your code. >> >> Stefan > > Not sure what you mean, but I tested and so far every document with > the same order of elements had number of comparisons equal to number > of nodes. Sorry, missed the "let2.remove(foundEl)" line. Stefan -- http://mail.python.org/mailm

Re: lxml, comparing nodes

2008-07-25 Thread code_berzerker
> Not in your code. > > Stefan Not sure what you mean, but I tested and so far every document with the same order of elements had number of comparisons equal to number of nodes. -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml, comparing nodes

2008-07-25 Thread Stefan Behnel
code_berzerker wrote: >> If document order doesn't matter, try sorting the elements of each level in >> the two documents by some arbitrary deterministic key, such as (tag name, >> text, attr count, whatever), and then compare them in order, instead of >> trying >> to find matches in multiple pass

Re: lxml, comparing nodes

2008-07-25 Thread code_berzerker
> If document order doesn't matter, try sorting the elements of each level in > the two documents by some arbitrary deterministic key, such as (tag name, > text, attr count, whatever), and then compare them in order, instead of trying > to find matches in multiple passes. itertools.groupby() might

Re: lxml, comparing nodes

2008-07-24 Thread Stefan Behnel
code_berzerker wrote: > Thanks for help. Thats inspiring, tho not exactly what I need, coz > ignoring document order is requirement (ignoring changes in order of > different siblings of the same type, etc). I plan to try something > like that: > > def xmlCmp(xmlStr1, xmlStr2): > et1 = etree.XML(

Re: lxml, comparing nodes

2008-07-24 Thread code_berzerker
> off the top of my head (untested): > >  >>> def equal(a, b): > ...     if a.tag != b.tag or a.attrib != b.attrib: > ...         return False > ...     if a.text != b.text or a.tail != b.tail: > ...         return False > ...     if len(a) != len(b): > ...         return False > ...     if any(not

Re: lxml, comparing nodes

2008-07-23 Thread Fredrik Lundh
code_berzerker wrote: Your requirements for a single Element are simple enough to write it in three to five lines of Python code (depending on your definition of equality). Checking this equality recursively is another two to three lines. Not complex enough to be considered a wheel in the first

Re: lxml, comparing nodes

2008-07-23 Thread code_berzerker
On Jul 23, 6:29 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Your requirements for a single Element are simple enough to write it in three > to five lines of Python code (depending on your definition of equality). > Checking this equality recursively is another two to three lines. Not complex >

Re: lxml, comparing nodes

2008-07-23 Thread Stefan Behnel
code_berzerker wrote: > I'd like to know if there is any built in mechanism in lxml that lets > you check equality of two nodes from separate documents. No, because, as you state yourself, equality is not something that everyone defines the same way. > I'd like it > to ignore attribute order and

Re: lxml, comparing nodes

2008-07-23 Thread Sebastian "lunar" Wiesner
code_berzerker <[EMAIL PROTECTED]>: > I'd like to know if there is any built in mechanism in lxml that lets > you check equality of two nodes from separate documents. I'd like it > to ignore attribute order and so on. It would be even better if there > was built in method for checking equality of

Re: lxml validation and xpath id function

2008-07-02 Thread Stefan Behnel
Floris Bruynooghe wrote: > I'm trying to use the .xpath('id("foo")') function on an lxml tree but > can't get it to work. Quick follow-up: this has been answered on the lxml mailing list: http://comments.gmane.org/gmane.comp.python.lxml.devel/3815 Stefan -- http://mail.python.org/mailman/listinf

  1   2   >