Re: [xml] Remove whitespaces from text nodes



void stripSpaces(xmlNodePtr node) //likely pass in the "children" of the root
{
    int len,i;

    for (;node;node=node->next) {
        if (node->type == XML_TEXT_NODE) {
            len = strlen(node->name);
            for (i=0;i<len;i++)
                if (node->name[i] != ' ')
                    break;
            if (i > 0)
                strcpy(node->name,&node->name[i]);
            len = strlen(node->name);
            for (i=len;i>0;i--) {
                if (node->name[i] != ' ')
                    break;
                node->name[i] = '\0';
            }
        }
    }
}


On 2/14/2012 2:43 PM, Michael Ludwig wrote:
Laurence Rowe schrieb am 14.02.2012 um 20:58 (+0000):
On 14 February 2012 09:59,<spam spam spam spam free fr>  wrote:
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?
Take a look at the xmllint source, it has a --noblanks option which
sets xmlKeepBlanksDefault(0);
But that doesn't get rid of non-ignorable whitespace.

$ xmllint --version
xmllint: using libxml version 20708

Michael
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]