Child removal problem with Xerces

Thread Solved
Reply

Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Child removal problem with Xerces

 
0
  #1
Mar 17th, 2009
I need help with the code below. At root->removeChild(nodeToRemove), I have a NOT_FOUND_ERR code. It is not supposed to return this code, because I look in the DOM Tree with IsInDocument.

Can someone tell me what's wrong with this code. I'm becoming blind with this code.

  1. DOMNode* nodeToRemove;
  2. if ((nodeToRemove = IsInDocument(root, *it)) != 0)
  3. {
  4. if (nodeToRemove->isEqualNode(root))
  5. {
  6. root = 0;
  7. break;
  8. }
  9. root->removeChild(nodeToRemove);
  10. }
  1. DOMNode* IsInDocument(DOMNode* node, DOMNode* toFind)
  2. {
  3. if (node->isEqualNode(toFind))
  4. {
  5. return node;
  6. }
  7. else
  8. {
  9. node = node->getFirstChild();
  10. while (node != 0)
  11. {
  12. DOMNode* retval;
  13. if ((retval = IsInDocument(node, toFind)) != 0)
  14. {
  15. return retval;
  16. }
  17. node = node->getNextSibling();
  18. }
  19.  
  20. return 0;
  21. }
  22. }

When I debug, this is where an exception is thrown.

  1. if (castToNodeImpl(this)->isReadOnly())
  2. throw DOMException(
  3. DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMParentNodeMemoryManager);
  4.  
  5. if (oldChild == 0 || oldChild->getParentNode() != castToNode(this))
  6. throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMParentNodeMemoryManager);
  7.  
  8. if (this->getOwnerDocument() != 0 ) {
  9. //notify iterators
  10. NodeIterators* nodeIterators = ((DOMDocumentImpl *)this->getOwnerDocument())->getNodeIterators();
  11. if (nodeIterators != 0) {
  12. XMLSize_t sz = nodeIterators->size();
  13. if (sz != 0) {
  14. for (XMLSize_t i =0; i<sz; i++) {
  15. if (nodeIterators->elementAt(i) != 0)
  16. nodeIterators->elementAt(i)->removeNode(oldChild);
  17. }
  18. }
  19. }
Last edited by GDICommander; Mar 17th, 2009 at 10:07 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Re: Child removal problem with Xerces

 
0
  #2
Mar 17th, 2009
Ok, I have found the error. removeChild is not a recursive function. Sorry for this self-solved thread.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC