[xml] xmlNewTextWriterTree, writerTree



I have modified an example from the libxml2 documentation to use
xmlNewTextWriterTree for writing to the tree
but it doesn't work unless I comment out 'critical':


void
testXmlwriterTree(const char *file)
{
    xmlTextWriterPtr writer;
    xmlDocPtr doc;
    xmlNodePtr node;

    // tested on the version 2.6.26
    doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
    node = xmlNewDocNode(doc, NULL, BAD_CAST "Alivemessage", NULL);

    xmlDocSetRootElement(doc, node);

    writer = xmlNewTextWriterTree(doc, node, 0);

    xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);

    xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
    xmlTextWriterEndElement(writer);
    /* begin critical*/
    xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
    xmlTextWriterEndElement(writer);
    /*
      Entity: line 2: parser error : Extra content at the end of the
document
      <HEADER/><ENTRIES/>

     */
    /* end critical*/
    xmlTextWriterEndDocument(writer);

    xmlFreeTextWriter(writer);

    xmlSaveFileEnc(file, doc, MY_ENCODING);

    xmlFreeDoc(doc);
}



                                    
________________________________________________________________________

K.Karamazen
Trinità Automatisering B.V.
Post-adres:  Postbus 189, 1420 AD Uithoorn
Bezoek-adres: J.N. Wagenaarweg 6, 1422 AK Uithoorn
Tel. : 0297 382460

Fax : 0297 273049
Email: kk trinite nl
Website: www.trinite.nl 




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