0

我的代码生成以下字符串,

XmlWriter obj1;
obj1.StartDocWriting("MyObject.xml");
obj1.SetRootNode("Object");
obj1.CreateChildNodeToRootWithProperty("age","20");         
obj1.CreateChildNodeToRootWithProperty("name","xyz");
obj1.xml_to_string(outbuf);

o/p xml 字符串,

<?xml version="1.0"?>
<Object><age>20</age><name>xyz</name></Object>

当我试图解析它时,我收到以下错误,

实体:第 3 行:解析器错误:文档末尾的额外内容

Here is my parsing code,

std:string inbuf = "<?xml version="1.0"?>
<Object><age>20</age><name>xyz</name></Object>"

 XmlTextReader obj1;
 xmlTextReaderPtr readPtr =  obj1.parseBuffer(inbuf.c_str(),10000);

xmlTextReaderPtr XmlTextReader::parseBuffer( const char *aInBuffer,
                                             int aInSize,
                                             const char * aInUrl,
                                             const char * aInEncoding,
                                             int aInOptions )
{
    xmlReader = xmlReaderForMemory( aInBuffer, aInSize, aInUrl, aInEncoding, aInOptions );
    if( xmlReader == NULL )
    {
       printf("reader is null");
       // LOG(LOG_INFO, "parseBuffer:: xmlReaderForMemory return NULL\n");
    }
    return xmlReader;
}  
4

0 回答 0