问题可能简单了点,因为我是新手,今天第一天接触XML.要给公司写一个JABBER客户端,需要解析XML.我选择使用 tinyXML
请问怎么构造如下这句XML? 我试了很多次,都没有成功. <iq type="get" id="131163156250"> <query xmlns="jabber:iq:auth"> <username>pee</username>
</query>
</iq>
问题一旦解决,分数即刻送上
谢谢

解决方案 »

  1.   

    /** Parse the given null terminated block of xml data. Passing in an encoding to this
    method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
    to use that encoding, regardless of what TinyXml might otherwise try to detect.
    */
    virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
    是不是用这个函数,我对tinyxml不熟悉
      

  2.   

    就是Parse函数他的参数是你上面写的xml片断
      

  3.   


    上面我写的那个片断是我已经构造好了的.我想怎么利用TinyXML的element, node, docment这些来构造一个XML而不是通过字符串相加的这种方式构造不想这样:string id = "131163156250>";
    string type = "get";
     
    string text = "<iq type=";
    text += type;
    text += id;...
    ...doc.parse(text.c_str());这样就失去了我使用TINYXML意义了
      

  4.   

    http://software.ellerton.net/tinyxml.html