xml - Java-Handling empty nodes in DOM -
i using java dom parse xml file, format elements , output csv further processing later. want skip on nodes empty or id attribute null , i'm not sure how go this.
below exerpt source code, if want full listing let me know!
... setup ... list<employee> emplist = new arraylist<>(); nodelist = document.getdocumentelement().getchildnodes(); (int = 0; < nodelist.getlength(); i++) { node = nodelist.item(i); if (node instanceof element) { employee emp = new employee(); emp.id = node.getattributes().getnameditem("id").getnodevalue(); nodelist childnodes = node.getchildnodes(); (int j = 0; j < childnodes.getlength(); j++) { ... identify child tags , add list.
thanks, shaw
Comments
Post a Comment