Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 C++。我想问一下如何从以下位置获取值文本:
<message> text </message>
我有
TiXmlHandle handle(&doc); TiXmlElement* section; section=doc.FirstChildElement("message");
从现在开始怎么做?我知道我必须合作,.Element()但我不知道如何。
.Element()
您可以使用该函数GetText()来获取<message>. 我将您的 XML 内容放在一个名为的文件中dummy.xml,并使用以下代码打印内容:
GetText()
<message>
dummy.xml
TiXmlDocument doc("dummy.xml"); if(doc.LoadFile()) { TiXmlHandle hDoc(&doc); TiXmlElement *pRoot; pRoot = doc.FirstChildElement("message"); printf("pRoot text: %s", pRoot->GetText()); }