我有一个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>
我需要 book 的子节点与 book 的顺序相同(没有父子节点)。生成的 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。有人可以帮助我吗?
谢谢