title: How can I write the following XML content with xmltextwriter of libxml2?
body: <p>I am trying to do xxxxx but facing issues with xxxxxxxxx. I have already searched on internet but didn't find any solution.Mainly I want to write namespace as URL using xmltextwriter.The content should look like as follows,</p>
  
  <pre><code>**&lt;!-- language-all: lang-xml --&gt;
  
      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;book
          xmlns="http://schemas.dmtf.org/ovf/environment/1"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
          oe:id=""&gt;
      &lt;/book&gt;
    **
  </code></pre>
  
  <p>code is here,</p>
  
  <pre><code>int main()
  {
    XmlWriter testWriter;
    testWriter.StartWriting("test.xml");
    testWriter.StartDocument("1.0","UTF-8");
  
    testWriter.StartElement("book");
  
    testWriter.StartIndenting();
  
    testWriter.AddAttributeNS("xmlns", "http://schemas.dmtf.org/ovf/environment/1", "", "http://schemas.dmtf.org/ovf/environment/1");
    testWriter.AddAttributeNS("xmlns", "http://www.w3.org/2001/XMLSchema-instance", "xsi", "http://www.w3.org/2001/XMLSchema-instance");
    testWriter.AddAttributeNS("xmlns", "http://schemas.dmtf.org/ovf/environment/1", "oe", "http://www.w3.org/2001/XMLSchema-instance");
    testWriter.AddAttributeNS("oe", ":", "id", "");
  
    testWriter.EndElement();
    testWriter.StopWriting();
  
    std::string buf;
    testWriter.xml_to_string(buf);
    return 0;
  }
  
  bool StartElement(const std::string&amp; element_name) {
         return xmlTextWriterStartElement(writer_,
                                       BAD_CAST element_name.c_str()) &gt;= 0;
  }
  
  bool XmlWriter::AddAttributeNS(const std::string&amp; name,
                          const std::string&amp; value,
                          const std::string&amp; prefix,
                          const std::string&amp; namespaceURI )
  {
  
        if(namespaceURI != "")
           return xmlTextWriterWriteAttributeNS (writer_,
                                              BAD_CAST prefix.c_str(),
                                              BAD_CAST name.c_str(),
                                              BAD_CAST namespaceURI.c_str(),
                                              BAD_CAST value.c_str()) &gt;= 0;
         else
           return xmlTextWriterWriteAttributeNS (writer_,
                                              BAD_CAST prefix.c_str(),
                                              BAD_CAST name.c_str(),
                                              NULL,
                                              BAD_CAST value.c_str()) &gt;= 0;
  
  
  }
  </code></pre>