需要以相同的顺序获取子节点

时间:2016-05-26 11:28:10

标签: c++ msxml msxml4

我有一个xml文件如下:

<bookstore>
    <book category="xyz">
        <title lang="en">some</title>
        <author>abc</author>
        <year>2005</year>
        <price>30.00</price>
    </book>
    <book category="children">
        <title lang="en">Harry Potter </title>
        <author>Rowling</author>
        <year>2005</year>
        <price>29.99</price>
    </book>
</bookstore>

我需要书籍的子节点与书籍的顺序相同(没有父子节点)。生成的xml应如下所示:

<bookstore>
    <book category="xyz">
    <title lang="en">some</title>
    <author>abc</author>
    <year>2005</year>
    <price>30.00</price>
    </book>
    <book category="children">
    <title lang="en">Harry Potter </title>
    <author>Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>
</bookstore>

相同的代码片段如下::

pXMLEventList = pXMLDoc->getElementsByTagName("book");
int numEvent = pXMLEventList->Getlength();
for(int evntCount = 0; evntCount < numEvent; evntCount++)
{   

    /*Read the xml file in a away wherein all the childnodes   
    at same level as of root node */
    pXMLEventDoc = pXMLEventList->item[evntCount];
    pXMLNodeList = pXMLEventDoc->getElementsByTagName("*");
    int count = pXMLNodeList->Getlength();
}   

但是pXMLEventDoc始终为NULL。有人可以帮助我。

谢谢

0 个答案:

没有答案