🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27677

Re: usuwanie pustych węzłów w XML-ach

#27677
From: Bart Ogryczak
Date: Thu, 23 Sep 2010 22:51
20 lines
1880 bytes
On Sep 21, 11:36 pm, blue <lukaszwojnow...@gmail.com> wrote:
> Mam sporą liczbę XML-i, które chce "odchudzić" czyli pousuwać z nich
> puste węzły np. wykorzystując bibliotekę lxml. Chodzi o to że mam np.
> coś takiego:
> <root>
>   <child>Child 1</child>
>   <child></child> -> węzeł do usunięcia
>   <another>Child 3</another>
> </root>
>
> Ogólnie chciałbym taką operację przeprowadzić dla wszystkich plików na
> raz (jest ich kilka tysięcy).

Nie sprawdzane, ale wg mnie powinno być coś takiego:

<xsl:template match="//">
 <xsl:if test = "current() != ''">
   <xsl:copy-of select="."/>
 </xsl:if>
</xsl:template>
Technical Details
Message-ID: <a6603b68-89d9-4aa8-87c7-f599b756649c@c13g2000vbr.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!feeder.erje.net!newsfeed.straub-nv.de!feeder.news-service.com!postnews.google.com!c13g2000vbr.googlegroups.com!not-for-mail
References: <2d9acd59-978a-4d7f-8ed0-b93a98a52a55@i17g2000vbq.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!feeder.erje.net!newsfeed.straub-nv.de!feeder.news-service.com!postnews.google.com!c13g2000vbr.googlegroups.com!not-for-mail
From: Bart Ogryczak <b.ogryczak@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Re: usuwanie pustych węzłów w XML-ach
Date: Thu, 23 Sep 2010 15:51:54 -0700 (PDT)
Organization: http://groups.google.com
Lines: 23
Message-ID: <a6603b68-89d9-4aa8-87c7-f599b756649c@c13g2000vbr.googlegroups.com>
References: <2d9acd59-978a-4d7f-8ed0-b93a98a52a55@i17g2000vbq.googlegroups.com>
NNTP-Posting-Host: 213.93.36.135
Mime-Version: 1.0
X-Trace: posting.google.com 1285282314 857 127.0.0.1 (23 Sep 2010 22:51:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 23 Sep 2010 22:51:54 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: c13g2000vbr.googlegroups.com; posting-host=213.93.36.135; posting-account=1kG_1AoAAADLEA3eucGvO2J-Uo4aPCW_
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8,gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit