Is there a way to get multiple tag names from lxml's lxml.etree.iterparse? I have a file-like object with an expensive read operation and many tags, so getting all tags or doing two passes is suboptimal.
Edit: It would be something like Beautiful Soup's find(['tag-1', 'tag-2]), except as an argument to iterparse. Imagine parsing an HTML...
I am using ElementTree and cannot figure out if the childnode is text or not. childelement.text does not seem to work as it gives false positive even on nodes which are not text nodes.
Any suggestions?
Example
<tr>
<td><a href="sdas3">something for link</a></td>
<td>tttttk</td>
<td><a href="tyty">tyt for link</a></td>
</tr>
Af...
Suppose I have this sort of HTML from which I need to select "text2" using lxml / ElementTree:
<div>text1<span>childtext1</span>text2<span>childtext2</span>text3</div>
If I already have the div element as mydiv, then mydiv.text returns just "text1".
Using itertext() seems problematic or cumbersome at best since it walks the entire tr...
Just a beginner question. I'm using "xml.etree.ElementTree" module to create an XML document with Python 3.1 from another structured document.
However, I cannot seem to locate an ElementTree function that returns the index of an existing subelement. I'm sure it's in there somewhere.
Any help would be much appreciated.
Thanks,
...
Hey. I want to have a config.xml file for settings in a Python web app.
I made car.xml manually. It looks like this:
<car>
<lights>
<blinkers>off</blinkers>
</lights>
</car>
Now I want to see whether the blinkers are on or off, using xml.etree.ElementTree.
import xml.etree.ElementTree as ET
tree = ET.parse('car.xml')...
Hi,
Environment: Windows,Python,wxpython and Element tree as xml parser.
I am developing a stand alone where it reads the xml and creates a tree.
My application reads the xml and creates tree but when xml changes next time(when DEPTH of xml increases- i mean when two child elements are added).Application fails to read(Logic fails :( )
...