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


Groups > comp.lang.python > #74992 > unrolled thread

Removing xml element and strip extra space

Started byvarun bhatnagar <varun292006@gmail.com>
First post2014-07-22 13:38 +0200
Last post2014-07-22 13:38 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Removing xml element and strip extra space varun bhatnagar <varun292006@gmail.com> - 2014-07-22 13:38 +0200

#74992 — Removing xml element and strip extra space

Fromvarun bhatnagar <varun292006@gmail.com>
Date2014-07-22 13:38 +0200
SubjectRemoving xml element and strip extra space
Message-ID<mailman.12178.1406029458.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi,

I am trying to play around with python and xslt. I have an xml and I want
to transform it to another xml by deleting its one element. The xml is
pasted below:

<?xml version="1.0" encoding="UTF-8"?>
<testNode>
<nodeInfo>
      <nodePeriod nodeTime="600000000"/>
      <nodeBase base="0" />
    </nodeInfo>
</testNode>


I want to remove the <nodeBase> tag and this is how my xsl file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>


<xsl:template match="/testNode/nodeInfo/nodeBase">
</xsl:template>

</xsl:stylesheet>

When I execute it my output looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<testNode>
<nodeInfo>
*      <nodePeriod nodeTime="600000000"/>*

*    </nodeInfo>*
</testNode>

I want to strip the space between *<nodePeriod>* and *</nodeInfo>*
Can anyone suggest a way out to do that?

Thanks,
BR,
Varun

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web