Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13285

libxml2dom quesiton

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <badouglas@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'test,': 0.04; 'chunk': 0.07; 'question.': 0.16; 'insert': 0.19; 'figure': 0.21; 'trying': 0.21; 'tree.': 0.23; 'import': 0.28; 'message-id:@mail.gmail.com': 0.29; 'print': 0.29; 'dom': 0.30; 'thanks': 0.30; 'this.': 0.32; 'to:addr:python-list': 0.33; 'follows:': 0.34; 'received:209.85.212': 0.34; 'test': 0.34; 'curious': 0.34; 'skip:- 40': 0.35; 'received:google.com': 0.38; 'received:209.85': 0.38; 'to:addr:python.org': 0.39; 'below': 0.62; 'node': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=v+a57jR/iDdNNKN/PqEIrymh8hDyZ8IWFKK5QaLFH5E=; b=yE57v7To136JDKz48tMI4AsKRR/mCLGb/eW3TumUB8ODAKOohjB7wcPKfpU1oJYjGH U+iErEiG7JZt69O9LG1Vjtr/Lks9+7qkeFkHMJJ4r6QqfU+UyJgo6ol18Hs0sKUEBz6m 5LQ+GW/TUrprG7uCcYj6VPXcw20D6okMHVIiY=
MIME-Version 1.0
Date Wed, 14 Sep 2011 13:16:41 -0700
Subject libxml2dom quesiton
From bruce <badouglas@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1129.1316031403.27778.python-list@python.org> (permalink)
Lines 79
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1316031404 news.xs4all.nl 2449 [2001:888:2000:d::a6]:51021
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:13285

Show key headers only | View raw


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


Thread

libxml2dom quesiton bruce <badouglas@gmail.com> - 2011-09-14 13:16 -0700

csiph-web