Re: [xml] Remove whitespaces from text nodes
- From: Michael Ludwig <milu71 gmx de>
- To: xml gnome org
- Subject: Re: [xml] Remove whitespaces from text nodes
- Date: Tue, 14 Feb 2012 21:13:19 +0100
spam spam spam spam free fr schrieb am 14.02.2012 um 10:59 (+0100):
I write a C program using the libxml2 library.
I would like to have this output (without editing my XML file) :
"My book "A""
"My book "B""
"My book "C""
The useless whitespaces are removed from text nodes.
Is there a function which do this work?
Don't know the C API, but in XSLT there's the function normalize-space()
and it does just what you want, so you might want to take a look at the
source of LibXSLT. Or use XSLT directly.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="text()" priority="2">
<xsl:copy-of select="normalize-space()"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Michael Ludwig
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]