Re: [Python] Xpath 2.0 e Python

2015-06-06 Per discussione Lorenzo Sutton
On 04/06/15 18:34, Andrea Gervasini wrote: [...] OUTPUT :1985 \n 1986 \n Un modo compatto (ma forse poco leggibile) potrebbe essere (assumendo che e sia un etree con l'XML): for i in e.iterfind('./tr'): print ''.join([x for x in i.itertext('td', with_tail=False)]) + "\\n", Lorenzo

Re: [Python] Xpath 2.0 e Python

2015-06-06 Per discussione Andrea Gervasini
Grazie ragazzi a tutti e due. Matteo, Dario. Risolto riusato tutti i vostri suggerimenti. On Thu, Jun 4, 2015 at 10:06 PM, Matteo Scarpa wrote: > from lxml import etree > root = etree.parse('x.xml') > result="" > for element in root.xpath('//a/tr'): > for single in element: > result

Re: [Python] Xpath 2.0 e Python

2015-06-04 Per discussione Matteo Scarpa
Qualcosa cosí? from lxml import etree root = etree.parse('x.xml') result="" for element in root.xpath('//a/tr'): for single in element: result=result+str(single.text) result=result+"/n" print(result) MS Il 04/06/2015 20:54, Dario Vinella ha scritto: Potresti provare lxml-xpath2

Re: [Python] Xpath 2.0 e Python

2015-06-04 Per discussione Dario Vinella
Potresti provare lxml-xpath2-functions In [9]: tree.xpath('string-join(//a/tr[1]/td, "")') Out[9]: '1985' ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python

[Python] Xpath 2.0 e Python

2015-06-04 Per discussione Andrea Gervasini
Qualcuno conosce una liberia python che gestisca bene xpath 2.0 ? Oppure una soluzione al seguente problema ? Ho un codice xml come il seguente 1 9 8 5 1 9 8