943,910 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 471
  • C++ RSS
Mar 17th, 2009
0

Child removal problem with Xerces

Expand Post »
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.

C++ Syntax (Toggle Plain Text)
  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. }
C++ Syntax (Toggle Plain Text)
  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.

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008
Mar 17th, 2009
0

Re: Child removal problem with Xerces

Ok, I have found the error. removeChild is not a recursive function. Sorry for this self-solved thread.
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: windows.h error
Next Thread in C++ Forum Timeline: Input Questions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC