create an XML file with wxXmlDocument

Éric Laly elaly at free.fr
Tue Oct 30 02:46:01 PDT 2007


Hello all,

I'm trying to create this kind of XML file:
<?xml version="1.0" encoding="utf8" ?>
<CONFIGURATIONS>
     <DEFAUT>
         <CADRE taille="1,0" ></CADRE>
         <CADRE taille="0,4" ></CADRE>
     </DEFAUT>
</CONFIGURATIONS>

for this I'm using this code:

wxXmlDocument configuration;
wxXmlNode *root=new wxXmlNode(wxXML_ELEMENT_NODE,wxT("CONFIGURATIONS"));
configuration.SetRoot(root);

wxXmlNode *nomConf=new wxXmlNode (wxXML_ELEMENT_NODE,wxT("DEFAUT"));
root->AddChild(nomConf);

wxXmlNode *cadre1=new wxXmlNode (wxXML_ELEMENT_NODE,wxT("CADRE"));
cadre1->AddProperty(wxT("taille"),wxT("1,0"));
nomConf->AddChild(cadre1);

wxXmlNode *cadre2=new wxXmlNode (wxXML_ELEMENT_NODE,wxT("CADRE"));
cadre2->AddProperty(wxT("taille"),wxT("0,4"));
nomConf->AddChild(cadre2);

// on sauve le fichier de configuration
if (!configuration.Save (wxT("config.xml"), 2))
{
   wxLogWarning (wxT("Problème avec la création du fichier de 
configuration %s"),wxT ("config.xml"));
}

and I get this:
<?xml version="1.0" encoding="utf-8"?>
<CONFIGURATIONS>
     <DEFAUT>
         <CADRE taille="1,0"/>
         <CADRE taille="0,4"/>
     </DEFAUT>
</CONFIGURATIONS>

I'm certainly doing something wrong but after having searching 
mailing-list, forum and googling, I haven't found nothing...

Is there a good soul on this ML ?

Thanks in advance.

Éric.





More information about the wx-users mailing list