Citation :
LIBXML_TEST_VERSION
int wRetour;
CDate wDtAujourdhui = CDate();
xmlTextWriterPtr writer;
// Création du fichier de paramètres
writer = xmlNewTextWriterFilename("Geline.xml", 0);
if (writer == NULL) return -1;
xmlTextWriterSetIndent(writer,1);
wRetour = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
if (wRetour < 0) return -2;
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Geline" );
if (wRetour < 0) return -3;
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Version",BAD_CAST PRODUCT_VERSION);
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Date",BAD_CAST wDtAujourdhui.dtCourante("D/M/Y H:I:S" ).c_str());
// On renseigne les options globales
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Options" );
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Option" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cFormatDate" );
if (cFormatDate.size() != 0) wRetour = xmlTextWriterWriteRaw(writer, BAD_CAST cFormatDate.c_str());
wRetour = xmlTextWriterEndElement(writer); // Option cFormatDate
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Option" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cFormatHeure" );
if (cFormatHeure.size() != 0)
wRetour = xmlTextWriterWriteRaw(writer, BAD_CAST cFormatHeure.c_str());
wRetour = xmlTextWriterEndElement(writer); // Option cFormatHeure
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Option" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cDernierFich" );
if (cDernierFich.size() != 0)
wRetour = xmlTextWriterWriteRaw(writer, BAD_CAST cDernierFich.c_str());
wRetour = xmlTextWriterEndElement(writer); // Option cDernierFich
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Option" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cRepAffiche" );
if (cRepAffiche.size() != 0)
wRetour = xmlTextWriterWriteRaw(writer, BAD_CAST cRepAffiche.c_str());
wRetour = xmlTextWriterEndElement(writer); // Option cRepAffiche
wRetour = xmlTextWriterEndElement(writer); // Options
// On renseigne les listes
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Listes" );
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Liste" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cFormatVid" );
for (int i = 0; i < cFormatVid.size(); i++)
xmlTextWriterWriteElement(writer, BAD_CAST "Item",BAD_CAST cFormatVid[i].c_str());
wRetour = xmlTextWriterEndElement(writer); // end Liste cFormatVid
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Liste" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cFormatAud" );
for (int i = 0; i < cFormatAud.size(); i++)
xmlTextWriterWriteElement(writer, BAD_CAST "Item",BAD_CAST cFormatAud[i].c_str());
wRetour = xmlTextWriterEndElement(writer); // end Liste cFormatAud
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Liste" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cGenre" );
for (int i = 0; i < cGenre.size(); i++)
xmlTextWriterWriteElement(writer, BAD_CAST "Item",BAD_CAST cGenre[i].c_str());
wRetour = xmlTextWriterEndElement(writer); // end Liste cGenre
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Liste" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cLangue" );
for (int i = 0; i < cLangue.size(); i++)
xmlTextWriterWriteElement(writer, BAD_CAST "Item",BAD_CAST cLangue[i].c_str());
wRetour = xmlTextWriterEndElement(writer); // end Liste cLangue
wRetour = xmlTextWriterStartElement(writer, BAD_CAST "Liste" );
wRetour = xmlTextWriterWriteAttribute(writer, BAD_CAST "Nom",BAD_CAST "cFichHisto" );
for (int i = 0; i < cFichHisto.size(); i++)
xmlTextWriterWriteElement(writer, BAD_CAST "Item",BAD_CAST cFichHisto[i].c_str());
wRetour = xmlTextWriterEndElement(writer); // end Liste cFichHisto
if (xmlTextWriterEndDocument(writer) < 0) return -3;
xmlFreeTextWriter(writer);
xmlCleanupParser();
return 0;
|