JAVA Ignore commented out xml tags -
while i'm parsing xml document, commented out code node (which bad idea begin with), wan't know when have commented out node/bulk , not parse it.
this code parses xml elements:
private static boolean updatexml(file file, document doc, nodelist nodelist) { if(nodelist==null) return false; boolean somethingchanged = false; for(int i=0;i<nodelist.getlength();i++) { if(nodelist.item(i).haschildnodes()) { somethingchanged |= updatexml(file, doc, nodelist.item(i).getchildnodes()); } else { ... } } }
and when debug it, can see commented out part brought 1 complete node.
how can ignore these comments?
use this:
node node = nodelist.item(i); if(node.getnodetype() == node.comment_node) { continue; } else { //do }
Comments
Post a Comment