Removing xml element and strip extra space
varun bhatnagar
varun292006 at gmail.com
Tue Jul 22 07:38:26 EDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140722/be99156e/attachment.html>
More information about the Python-list
mailing list