可编程创建的tinyxml xml 文件未在 Internet Explorer 中加载

发布于 2024-11-27 03:55:05 字数 8310 浏览 4 评论 0原文

我遵循的所有tinyxml 示例都生成了我能够在Internet Explorer 中查看的xml 文件。

然而,当我以编程方式创建我的时,IE 中没有任何显示。不过,我可以确认 xml 文件具有我期望的一切。

这是创建 xml 的代码:

bool InputIO::saveDevice( const std::string & fileName, const InputDevice& device ) const
    {

        TiXmlDocument doc;
        TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
        doc.LinkEndChild( decl );  
        TiXmlElement* root = new TiXmlElement("Input Devices");
        doc.LinkEndChild(root);
        TiXmlElement* dev = new TiXmlElement("Device");
        root->LinkEndChild(dev);
        dev->SetAttribute("number",1);
        for(int p = 0; p < 2; ++p)
        {
            for(int i = 0; i < NUM_KEYS; ++i)
            {
                //Primary configuration when p is 0
                InputKey key = device.getKey(InputEvent::Uniform_inputEnum(i),p == 0);

                TiXmlElement* button = new TiXmlElement("button");
                dev->LinkEndChild(button);
                button->SetAttribute("configuration",p);
                button->SetAttribute("number",i);
                button->SetAttribute("input type",key.inputType);
                button->SetAttribute("key code",key.keyCode);
                button->SetAttribute("joy axis",key.axis);
                button->SetAttribute("joy button",key.button);
                button->SetAttribute("joy stick",key.stick);

                if(key.positiveAxis)
                {
                    button->SetAttribute("axis direction","positive");
                }
                else
                {
                    button->SetAttribute("axis direction","negative");
                }
            }

        }
        doc.SaveFile(fileName.c_str());
        return true;
    }

这是生成的 xml

<?xml version="1.0" ?>
<Input Devices>
    <Device number="1">
        <button configuration="0" number="0" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="1" input type="1" key code="216" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="2" input type="1" key code="84" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="3" input type="1" key code="85" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="4" input type="1" key code="82" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="5" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="6" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="7" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="8" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="9" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="10" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="11" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="12" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="13" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="14" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="15" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="16" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="17" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="18" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="19" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="20" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="0" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="1" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="2" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="3" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="4" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="5" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="6" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="7" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="8" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="9" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="10" input type="1" key code="83" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="11" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="12" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="13" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="14" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="15" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="16" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="17" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="18" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="19" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="20" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
    </Device>
</Input Devices>

All of the examples I followed for tinyxml resulted in xml files that I was able to view in Internet Explorer.

However, when I programmably created mine, nothing showed in IE. I can confirm however that the xml file has everything I expect it to have.

Here is the code to create the xml:

bool InputIO::saveDevice( const std::string & fileName, const InputDevice& device ) const
    {

        TiXmlDocument doc;
        TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
        doc.LinkEndChild( decl );  
        TiXmlElement* root = new TiXmlElement("Input Devices");
        doc.LinkEndChild(root);
        TiXmlElement* dev = new TiXmlElement("Device");
        root->LinkEndChild(dev);
        dev->SetAttribute("number",1);
        for(int p = 0; p < 2; ++p)
        {
            for(int i = 0; i < NUM_KEYS; ++i)
            {
                //Primary configuration when p is 0
                InputKey key = device.getKey(InputEvent::Uniform_inputEnum(i),p == 0);

                TiXmlElement* button = new TiXmlElement("button");
                dev->LinkEndChild(button);
                button->SetAttribute("configuration",p);
                button->SetAttribute("number",i);
                button->SetAttribute("input type",key.inputType);
                button->SetAttribute("key code",key.keyCode);
                button->SetAttribute("joy axis",key.axis);
                button->SetAttribute("joy button",key.button);
                button->SetAttribute("joy stick",key.stick);

                if(key.positiveAxis)
                {
                    button->SetAttribute("axis direction","positive");
                }
                else
                {
                    button->SetAttribute("axis direction","negative");
                }
            }

        }
        doc.SaveFile(fileName.c_str());
        return true;
    }

And here is the resulting xml

<?xml version="1.0" ?>
<Input Devices>
    <Device number="1">
        <button configuration="0" number="0" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="1" input type="1" key code="216" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="2" input type="1" key code="84" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="3" input type="1" key code="85" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="4" input type="1" key code="82" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="5" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="6" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="7" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="8" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="9" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="10" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="11" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="12" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="13" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="14" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="15" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="16" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="17" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="18" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="19" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="0" number="20" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="0" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="1" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="2" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="3" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="4" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="5" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="6" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="7" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="8" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="9" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="10" input type="1" key code="83" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="11" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="12" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="13" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="14" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="15" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="16" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="17" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="18" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="19" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
        <button configuration="1" number="20" input type="0" key code="0" joy axis="0" joy button="0" joy stick="0" axis direction="positive" />
    </Device>
</Input Devices>

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

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

发布评论

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

评论(1

岁月无声 2024-12-04 03:55:05

W3 XML Validator 程序告诉我们关于您的 XML 的信息:

XML Parsing Error: not well-formed 
Location: http://www.w3schools.com/xml/xml_validator.asp 
Line Number 2, Column 15: <Input Devices>
                          --------------^

最后,您终止输入设备有问题,但是空间有什么问题。之后,您的 XML 就会遇到更多问题。请参阅此处,了解如何使 XML 格式良好

The W3 XML Validator program tells us this about your XML:

XML Parsing Error: not well-formed 
Location: http://www.w3schools.com/xml/xml_validator.asp 
Line Number 2, Column 15: <Input Devices>
                          --------------^

At the end, you terminate Input Devices, but the space is what is wrong. After that, you have more problems with your XML. See here for how to make your XML well-formed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文