c++xml-namespacestinyxml

Create xmlns using tinyxml


I am new to tinyxml, I would like to generate the following xml file using tinyxml library. Could you please help me out with this many thanks

<?xml version="1.0" encoding="utf-8" ?>    
    <geo:Sim xmlns:geo="http://www.xxx/geo"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.xxx/geo file:/geoX.xsd">
 <GG>
 </GG>
</geo:Sim>

Solution

  • TinyXML does not know or care about namespaces. However, that doesn't mean you can't use them. You just have to write namespace declarations like they were regular attributes. So if you want to define the geo namespace, make an attribute named xmlns:geo and give it the value of the namespace. And so forth.

    Similarly, the element will have to be named geo:Sim.