2

タグ間のコンテンツを取得するにはどうすればよいですか

<name>  </name> and <mode> </mode>

<news>
    <name>Enter</name>
    <actions>
      <mode>me</mode>
    </actions>
   </news>
4

2 に答える 2

5

TinyXMLの優れたドキュメントとチュートリアルを実際に確認する必要があります。ただし、探しているのGetText()はTiXmlElementのメソッドです。

「name」または「mode」要素に到達したら、これらのタグ間の文字列を。で取得できますGetText()

于 2012-02-27T12:25:01.647 に答える
1

\ これ

TiXmlDocument doc("tes.xml");

   if (doc.LoadFile())
  {
     TiXmlHandle hDoc(&doc);
   TiXmlText* text = hDoc.ChildElement("news", 0).ChildElement("act-news", 0).ChildElement("name", 0).FirstChild().Text();
if(text)
{
const char* message = text->Value();
cout<<(message)<<endl; 
 } 

TiXmlText* stext = hDoc.ChildElement("news", 0).ChildElement("act-news", 1).ChildElement("name", 0).FirstChild().Text();
if(text)
{
const char* message = stext->Value();
cout<<(message)<<endl; 
于 2012-02-29T23:31:31.367 に答える