[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12449251 ] Auber Lin commented on XMLBEANS-296: ------------------------------------
Here i posted a part of my code to remove the ith library instance element from ModuleSA element with key. As the library instances were added with comments (i use insertComment() from XmlCursor), deleting these library instances should also delete those comments added. But the result is that comments are left untouched and library instances are removed. public void removeLibraryInstance(String key, int i) { ModuleSADocument.ModuleSA msa = getModuleSA(key); if (msa == null || msa.getLibraries() == null){ return ; } XmlCursor cursor = msa.getLibraries().newCursor(); if (cursor.toFirstChild()) { for (int j = 0; j < i; ++j) { cursor.toNextSibling(); } cursor.push(); // Try to get the comment part by moving cursor while (cursor.hasPrevToken()) { cursor.toPrevToken(); if (!cursor.isText()) { break; } String s = cursor.getTextValue(); if (s.matches(regExpNewLineAndSpaces)) { continue; } } if (cursor.isComment()) { cursor.removeXml(); } cursor.pop(); cursor.removeXml(); if (getLibraryInstancesCount(key) == 0) { cursor.toParent(); cursor.removeXml(); } } cursor.dispose(); } > Xml comments are ignored by XmlBeans > ------------------------------------ > > Key: XMLBEANS-296 > URL: http://issues.apache.org/jira/browse/XMLBEANS-296 > Project: XMLBeans > Issue Type: Bug > Affects Versions: Version 2.1 > Environment: WindowsXp + JDK1.5.0-6 > Reporter: Auber Lin > Priority: Blocker > > When a xml file contains some comments like <!--comment statements-->, these > comments are not included into the document object created by xmlbeans. so if > an application accessing xml file using xmlbeans, there is no way for it to > modify or delete these already-existed comments. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]