小编Ric*_*udo的帖子

miniXML解析C API

我正在尝试解析以下XML文件:

<root>Root
    <pai>Pai_1
        <filho>Pai1,Filho1</filho>
        <filho>Pai1,Filho2</filho>
    </pai>
    <pai>Pai_2
        <filho>Pai2,Filho1</filho>
        <filho>Pai2,Filho2</filho>
    </pai>
</root>
Run Code Online (Sandbox Code Playgroud)

我正在使用以下C代码:

//... open file
xml_tree = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK);

node = xml_tree;
printf("%s\n", mxmlGetText(node, NULL));
// here the return is: Root
// I expected: Root, OK

node = xml_tree->child;
printf("%s\n", mxmlGetText(node, NULL));
// here the return is: Root
// I expected: Pai_1, not OK

node = mxmlGetFirstChild(xml_tree);
printf("%s\n", mxmlGetText(node, NULL));
// here the return is: Root
// I expected: Pai_1, not OK

node = mxmlFindElement(xml_tree, xml_tree, "pai", NULL, NULL, …
Run Code Online (Sandbox Code Playgroud)

c xml xml-parsing mini-xml

3
推荐指数
2
解决办法
6404
查看次数

标签 统计

c ×1

mini-xml ×1

xml ×1

xml-parsing ×1