0

I've the following XML:

<?xml version="1.0" encoding="utf-8"?>
<jack>
    <client name="Music Player Daemon">
        <port name="left">
            <connection port="jamin:in_L" />
        </port>
        <port name="right">
            <connection port="jamin:in_R" />
        </port>
    </client>
</jack>

I'm trying to parse it using PugiXML but after load my document is empty, the result description say no error:

pugi::xml_document doc;
pugi::xml_parse_result result = doc.load("/location/filename.xml");
std::cout << "Load result: " << result.description() << std::endl;

but it's a empty doc:

std::size_t numitens = std::distance(doc.begin(), doc.end());
std::cout << numitens << std::endl;

Output:

Load result: No error
0

I think that XML isn't problem, right ?

The XML is generated by other app, so I can't change, if have a problem in XML I'll need change XML parser ? TinyXML or libxml++ ?

4

1 回答 1

1

doc.load() loads the string, not the file. You have to use doc.load_file().

Ideally the parsing of the string "/location/filename.xml" should've failed; there are complicated reasons why it does not, mostly related to backwards compatibility.

于 2013-06-27T08:00:10.660 回答