id summary reporter owner description type status priority milestone component version severity resolution keywords cc 1598 CPLRemoveXMLChild doesn't work (And I can't figure out how it's supposed to warmerdam warmerdam " From Scott J Waguespack: I had a bug in my program that I had to go through the trouble of building GDAL and Xerces to track down, and here's what I've come to: CPLRemoveXMLChild It's supposed to cleanly remove a child from the parent's list of children. Instead, it seems to simply set the parent's psChild to NULL. Naturally, I decided to step through the function to see what was happening. int CPLRemoveXMLChild( CPLXMLNode *psParent, CPLXMLNode *psChild ){ CPLXMLNode *psLast = NULL, *psThis; if( psParent == NULL ) return FALSE; for( psThis = psParent->psChild; psThis != NULL; psThis = psThis->psNext ){ if( psThis == psChild ) { if( psLast == NULL ) psParent->psChild = psThis->psNext; else psLast->psNext = psThis->psNext; psThis->psNext = NULL; return TRUE; } } return FALSE; } So, first off, it sets psLast to Null, never changes it, then uses it in an if statement. Then, the line of code which is now bound to be executed when the child is found sets psParent's child to the psChild's next sibling, eliminating all of the previous sibling that should still belong to the parent. The ultimate result is that it eliminates all siblings up until the psChild's (the psChild to be removed) next sibling. As far as I can tell, this is what the method should be doing reliably, and it's what I've observed it doing in practice. This contradicts what it is stated to be doing in the documentation. " defect closed normal 1.4.2 default unspecified normal fixed