解析在 TinyXML 中

发布于 2024-09-26 11:25:07 字数 213 浏览 5 评论 0 原文

如何在 TinyXML 中解析以下内容:

<multi_path literal="not_measured"/>

我能够轻松解析以下行:

<hello>1234</hello>

问题是第一个语句没有以正常方式解析。请建议如何解决这个问题。

How do I parse the following in TinyXML:

<multi_path literal="not_measured"/>

I am able to easily parse the below line:

<hello>1234</hello>

The problem is that the first statement is not getting parsed the normal way. Please suggest how to go about this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐籹人 2024-10-03 11:25:07

不能 100% 确定您的问题是什么,但这里有一个使用tinyXML 循环遍历 XML 文件的基本格式:

/*XML format typically goes like this:
<Value atribute = 'attributeName' >
Text
</value>
*/
TiXmlDocument doc("document.xml");
bool loadOkay = doc.LoadFile(); // Error checking in case file is missing
if(loadOkay)
{
    TiXmlElement *pRoot = doc.RootElement();
    TiXmlElement *element = pRoot->FirstChildElement();
    while(element)
    {
        string value = firstChild->Value(); //Gets the Value
        string attribute = firstChild->Attribute("attribute"); //Gets the attribute
        string text = firstChild->GetText(); //Gets the text
        element = element->NextSiblingElement();
    }
}
else
{
    //Error conditions
} 

Not 100% sure what youre question is asking but here is a basic format too loop through XML files using tinyXML:

/*XML format typically goes like this:
<Value atribute = 'attributeName' >
Text
</value>
*/
TiXmlDocument doc("document.xml");
bool loadOkay = doc.LoadFile(); // Error checking in case file is missing
if(loadOkay)
{
    TiXmlElement *pRoot = doc.RootElement();
    TiXmlElement *element = pRoot->FirstChildElement();
    while(element)
    {
        string value = firstChild->Value(); //Gets the Value
        string attribute = firstChild->Attribute("attribute"); //Gets the attribute
        string text = firstChild->GetText(); //Gets the text
        element = element->NextSiblingElement();
    }
}
else
{
    //Error conditions
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文