hi,
i'm new to python and cssselect.
i'm trying to get some links from a webpage.
http://pastebin.com/w35S8dJm
i have not the slightest idea why the specified selector does not return the exptected results.
the selector does return the expected results in chrome console and firebug console.
thanks in advance for your help!
axel
Hello,
given the following piece of code which replaces all A nodes in P with B:
>>> tree = etree.fromstring("<P><A/><A/></P>")
>>> l = tree.findall("A")
>>> first, last = tree.index(l[0]), tree.index(l[-1])
>>> tree[first : last + 1] = [ etree.Element("B") ]
>>> etree.tostring(tree)
'<P><B/></P>'
This code works, but it feels kind of ugly.
Is there a more elegant way to replace a slice of the list …
[View More]of children
(actually all children having the same name, but they always appear in a row)
with another list of elements and keeping the document order intact?
TIA, Markus
[View Less]
Thanks for your reply Stefan. I'll look into the threads you pointed out in more detail.
I am kinda glad that I didn't miss an obvious solution =)
My need is rather simplistic, so maybe I can try to querying the schema.
I did read a little bit about "Abbot" from MONK -- http://quest.library.illinois.edu/monk/project/ -- per Martin's suggestion (Thanks!), but it seems like it is no longer active and it is not a direct solution to my issue.
Thanks!Aaron
On Sunday, March 1, 2015 7:…
[View More]00 AM, "lxml-request(a)lxml.de" <lxml-request(a)lxml.de> wrote:
Date: Sat, 28 Feb 2015 21:28:37 +0100
From: Stefan Behnel <stefan_ml(a)behnel.de>
To: lxml(a)lxml.de
Subject: Re: [lxml] Programmatically accessing schema
Message-ID: <54F224F5.3030200(a)behnel.de>
Content-Type: text/plain; charset=utf-8
Aaron Storm schrieb am 28.02.2015 um 12:29:
> I went through the documentation and couldn't find any hints on this.
> And I am not sure what keywords to search on google. Is there a way to
> programmatically (or api?) query the XSD for a specific element to get
> its spec? For example, I would like to know if /MyContainer/Container2
> can be repeated. Or if /MyContainer/Container1/Item1/ text() is
> optional.
Similar questions have been discussed in the past. These are related, for
example:
http://thread.gmane.org/gmane.comp.python.lxml.devel/7318http://thread.gmane.org/gmane.comp.python.lxml.devel/5619
In general, figuring out what an XML Schema specification allows is rather
difficult. It can be done for simple cases (it's XML, you can search in
it), but schemas can be arbitrarily complex. Sometimes there are multiple
ways to express something, and covering all cases is cumbersome.
Stefan
[View Less]