我有一个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。有人可以帮助我。
谢谢