Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #13285
| Date | 2011-09-14 13:16 -0700 |
|---|---|
| Subject | libxml2dom quesiton |
| From | bruce <badouglas@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1129.1316031403.27778.python-list@python.org> (permalink) |
Hi.
Test question. Trying to see how to insert a test node into an
existing dom tree. For the test, it has a TR/TD with a
td[@class="foo"] that has an associated TR..
Trying to figure out how out how to insert a "<DIV></DIV>" around the
tr/td in question...
Curious as to how to accomplish this.
Thoughts/pointers.
thanks
--------------------------
sample code/html chunk follows:
import libxml2dom
text is below
tt = libxml2dom.parseString(text, html=1)
t1path_=tt.xpath(t1path)
aa=tt.createElement("<div>")
print len(t1path_)
for a in t1path_:
tt.insertBefore(aa,None)
print a.nodeName
print a.toString()
sys.exit()
--------------------------------------------
s3==
<html>
<body>
<tr>
<td class="foo">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td class="foo">
</td>
</tr>
</body>
</html>
trying to get::
<html>
<body>
<div>
<tr>
<td class="foo">
</td>
</tr>
</div>
<tr>
<td>
</td>
</tr>
<div>
<tr>
<td class="foo">
</td>
</tr>
</div>
</body>
</html>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
libxml2dom quesiton bruce <badouglas@gmail.com> - 2011-09-14 13:16 -0700
csiph-web