Code: Alles auswählen
In [12]: "".join(root.xpath("//titel/text()"))
Out[12]: '\nHalloWelt!. Du bist schön!\n Und ich hoffe so! '
Code: Alles auswählen
In [12]: "".join(root.xpath("//titel/text()"))
Out[12]: '\nHalloWelt!. Du bist schön!\n Und ich hoffe so! '
Code: Alles auswählen
In [412]: print ''.join(doc.xpath('titel//text()'))
HalloWelt!. Du bist so schön!
Und ich hoffe das bleibt so!Oops, stimmt. [ausredenmodus]Zu viel Ruby heute...BlackJack hat geschrieben:@Hyperion: Da fehlte ein '/':
Code: Alles auswählen
import lxml.etree as ET
doc = ET.parse("datasheet.xml")
def test(knoten):
data = ET.tostring(doc)
root = ET.fromstring(data)
print ''.join(root.xpath(knoten+'//text()'))Code: Alles auswählen
root = tree.getroot()