[Help] MFC ypelib wrappers for MSXML5
-
I am currently using the Typelib wrappers for MSXML that was generated from the MFC Typelib Class wizard. I think I am using the objects incorrectly, and this is generating unhandled exception errors. I use wizard MFC Class from Typelib to generate wrapper classes for the MSXML5 control (CXMLDOMDocument, CXMLDOMElement, CXMLDOMNode, and CXMLNodeList). The exception occurs when I pass a CXMLDOMNode reference to a function that I want it to work on by stepping down farther in the node tree. For example: If(m_XMLDOMroot.hasChildNodes()) { int rootchildcount = RootNodeList.get_length(); for(int i = 0; i < rootchildcount; ++i) { CXMLDOMElement childnode = RootNodeList.get_item(i); <- This code sometimes user breaks SetChildNode(childnode); } } Robert
-
I am currently using the Typelib wrappers for MSXML that was generated from the MFC Typelib Class wizard. I think I am using the objects incorrectly, and this is generating unhandled exception errors. I use wizard MFC Class from Typelib to generate wrapper classes for the MSXML5 control (CXMLDOMDocument, CXMLDOMElement, CXMLDOMNode, and CXMLNodeList). The exception occurs when I pass a CXMLDOMNode reference to a function that I want it to work on by stepping down farther in the node tree. For example: If(m_XMLDOMroot.hasChildNodes()) { int rootchildcount = RootNodeList.get_length(); for(int i = 0; i < rootchildcount; ++i) { CXMLDOMElement childnode = RootNodeList.get_item(i); <- This code sometimes user breaks SetChildNode(childnode); } } Robert
Is SetChildNode(...) removing nodes/elements from the NodeList? This causes the length of the NodeList to decrease as your looping which causes 2 errors. 1) If rootchildcount was originally 10, and nodes are being removed, your still comparing against a length of 10, even though there are fewer than 10 nodes in the list. 2) Incrementing i for any iteration where a node was removed from the list, will cause your code to skip over the node (in the nodelist) following the node that was just removed.
-
Is SetChildNode(...) removing nodes/elements from the NodeList? This causes the length of the NodeList to decrease as your looping which causes 2 errors. 1) If rootchildcount was originally 10, and nodes are being removed, your still comparing against a length of 10, even though there are fewer than 10 nodes in the list. 2) Incrementing i for any iteration where a node was removed from the list, will cause your code to skip over the node (in the nodelist) following the node that was just removed.
To answer you question, and give move clarification. I am not removing any nodes. I am just accessing them to pull the information out of the nodes. I have notice that in some case the nodelist size if different sizes, cause sometimes there is a TEXT_Element in the list. I just do not understand this nomial yet. But this is for different files. Robert -- modified at 14:10 Thursday 10th August, 2006
-
To answer you question, and give move clarification. I am not removing any nodes. I am just accessing them to pull the information out of the nodes. I have notice that in some case the nodelist size if different sizes, cause sometimes there is a TEXT_Element in the list. I just do not understand this nomial yet. But this is for different files. Robert -- modified at 14:10 Thursday 10th August, 2006
I would suggest that you change your code to check the length of the node list on every iteration of the loop.
if(m_XMLDOMroot.hasChildNodes())
{
for(int i = 0; i < RootNodeList.get_length(); ++i)
{
CXMLDOMElement childnode = RootNodeList.get_item(i); <- This code sometimes user breaks
SetChildNode(childnode);
}
} -
I would suggest that you change your code to check the length of the node list on every iteration of the loop.
if(m_XMLDOMroot.hasChildNodes())
{
for(int i = 0; i < RootNodeList.get_length(); ++i)
{
CXMLDOMElement childnode = RootNodeList.get_item(i); <- This code sometimes user breaks
SetChildNode(childnode);
}
} -
I did what you sugguested, and the size of the rootNodeList is not changing. So any other sugguestions? BTW- Thanks for all the help given so far. Robert
What's the exception your getting?