【问题标题】:How do I get the name of a tag in TinyXML?如何在 TinyXML 中获取标签的名称?
【发布时间】:2011-11-18 20:53:26
【问题描述】:

例如:

test.xml

<fruit taste="good">whatever</fruit>

如何使用 TinyXML 获取标签“fruit”(当然是“fruit”)的名称字符串?

【问题讨论】:

    标签: c++ xml tinyxml


    【解决方案1】:

    使用TiXmlElement::Value()

    Value 函数根据类型返回不同的东西。

        Document:   filename of the xml file
        Element:    name of the element
        Comment:    the comment text
        Unknown:    the tag contents
        Text:       the text string
    

    【讨论】:

    • 忘了说如果你使用STL,你也可以使用TiXmlNode::ValueStr(),它返回const std:string&amp;而不是const char *。它也更有效率。
    猜你喜欢
    • 2014-07-12
    • 1970-01-01
    • 2019-11-29
    • 2017-04-23
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多