appendChild xml c++无法按需工作
appendChild xml c++ not working as needed
为什么在执行appendChild
之后,我无法读取下一个节点?
(newChildList->get_item(count,&pNewChild))
appendChild
API没有正常工作。在我放入这行之后,我无法在循环中获得下一个get_item()
。返回pNewChild
,即NULL
。为什么会发生这种情况?
IXMLDOMNode *pNewChild=NULL,*outNewChild;
IXMLDOMNodeList *newChildList=NULL;
BSTR newName;
long len=0;
HRESULT hr=S_OK;
//aggregate attribute
//CHK_HR(aggregateAttribute(pNodeNew,pXMLDomSrc,pXMLDomNew));
//read the list of child
CHK_HR(pNodeNew->get_childNodes(&newChildList));
CHK_HR(newChildList->get_length(&len));
//go over all the children
for(long count=0;count<len;count++)
{
hr =newChildList->get_item(count,&pNewChild);
CHK_HR(pNewChild->get_nodeName(&newName));
USES_CONVERSION;
string temp= W2T(newName);
temp = temp.substr(temp.find_first_of("/:")+1);
if (!temp.compare("tuple"))
{
//CHK_HR(aggregateTuple(pXMLDomSrc,pNewChild));
}
else
{
CHK_HR(pXMLElement->appendChild(pNewChild,&outNewChild));
}
SAFE_RELEASE(pNewChild);
//SysFreeString(newName);
}
CleanUp:
//SAFE_RELEASE(newChildList);
SAFE_RELEASE(pNewChild);
return hr;
appendChild将节点移动到其他位置,每次将子列表减少一个。
试试这个:
// reverse loop from index base 0 "len-1" to 0
for(long count=len-1;count>=0;--count)
附带说明一下,您泄漏了大量内存(outNewChild
和newName
)
相关文章:
- QSqlquery prepare()和bindvalue()不工作
- Cppcheck生成xml转储文件
- 导入库可以跨dll版本工作吗
- 以螺旋方式打印矩阵的程序.(工作不好)
- 对象指针在c++中是如何工作的
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 为字符串中每 N 个字符插入空格的函数没有按照我认为的方式工作?
- C++为线程工作动态地分割例程
- 为什么我的 std::ref 无法按预期工作?
- 布尔比较运算符是如何在C++中工作的
- SampleConsensusPrerejective(ext.RANSAC)是如何真正工作的
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 为什么std::condition_variable notify_all的工作速度比notify_one快(对于随机请
- <<操作员在下面的行中工作
- 如何在pugixml中获取节点的内部XML
- 如何使用tinyxml2从XML加载父实体和子实体
- 有人能解释一下为什么下界是这样工作的吗C++的
- 提高精神难度,从XML示例工作
- appendChild xml c++无法按需工作