Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Can I edit xml files?

Developer
dschu012
2010-08-10
2013-05-20
  • dschu012
    dschu012
    2010-08-10

    I was reading some example code for TinyXML
    http://www.grinninglizard.com/tinyxmldocs/tutorial0.html
    However none of them seem to open up an XML file and add elements to it and then save it. Is this a limitation to TinyXML. If not can someone give sample code I assume it can be done something like

    TiXmlDocument doc(pFilename);
    if(doc.LoadFile())
    {
         //add some elements
    }
    doc.SaveFile(pFilename);
    
     

  • Anonymous
    2010-08-11

    TiXmlElement inherits from TiXmlNode (see this inheritence diagram)) which exposes several Insert* related methods. Attributes can be set/changed via the SetAttribute methods on TiXmlElement.