RE: [xml] A question about '&'



I apologize if I'm just missing the obvious here, but a simple code as
following seems doesn't work:
#include "libxml/parser.h"
int main(int argc, char* argv[])
{
        xmlDocPtr pXMLDOCdoc;
        pXMLDOCdoc=xmlNewDoc((const unsigned char *)("1.0"));
        pXMLDOCdoc->children=xmlNewDocNode(pXMLDOCdoc,NULL,(const unsigned
char *)("TEST"),NULL);
        xmlNewChild(pXMLDOCdoc->children,NULL,(const unsigned char
*)"Property",
                        (const unsigned char *)"A&W");
        xmlSaveFile("c:\\test.xml",pXMLDOCdoc);
        return 0;
}
In c:\test.xml I got:

<?xml version="1.0"?>
<TEST><Property>A</Property></TEST>

Instead of

<?xml version="1.0"?>
<TEST><Property>A&amp;W</Property></TEST>

Any ideas? 
I am using xmllib ver 2.3.8, vc++6.0+sp5, windows 2000 pro+sp1.
By the way, xmlKeepBlanksDefault(0) seems doesnt work under window 2000. You
can prove this by using xmllint -debug -noblans gjobs.xml. Please have a
look of this issue. Thank you very much for your help again.   

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Thursday, May 03, 2001 00:14
To: Ming Lu
Cc: xml gnome org
Subject: Re: [xml] A question about '&'


On Wed, May 02, 2001 at 03:36:52PM -0700, Ming Lu wrote:
Thank you very much for your replay and I still wonder if xml lib escape
'>','<',''' and'"' automatically, should it also escape '&'?

  yes, it does on output,

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




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