Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > libxml2dom quesiton

Reply
Thread Tools

libxml2dom quesiton

 
 
bruce
Guest
Posts: n/a
 
      09-14-2011
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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python/libxml2dom questions bruce Python 3 07-02-2006 06:25 AM
problems with libxml2dom ankit Python 1 01-04-2006 11:36 PM
Problem installing libxml2dom on windows ankit Python 4 12-28-2005 01:52 PM
libxml2dom problems ankit Python 2 12-28-2005 04:40 AM
problem with libxml2dom ankit Python 0 12-27-2005 06:43 AM



Advertisments