Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. ArrayList<String>textcomment = new ArrayList<String>();
  2. for(int i = 0;i<nl.getLength();i++)
  3. {
  4. Element e = (Element)nl.item(i);
  5. // crash on this string find first time a value and second time find </no_of_comments>
  6. String noOfcomment = e.getElementsByTagName("no_of_comments").item(0).getFirstChild ().getNodeValue();
  7. aryNoOfcomment.add(i, noOfcomment);
  8. }
  9.  
  10. String noOfcomment = e.getElementsByTagName ("no_of_comments"). item (0). getFirstChild (). getNodeValue ();
  11.  
  12. List<String> yourList = new ArrayList<String>();
  13. NodeList nl = e.getElementsByTagName ("no_of_comments");
  14. if(nl != null){
  15. for(int i = 0;i<nl.getLength();i++)
  16. {
  17. Node n = nl.item(i).getFirstChild();
  18. if(n!=null){
  19. String value = n.getNodeValue();
  20. yourList.add(value);
  21. }
  22. }
  23. }
  24.  
  25. FileInputStream fi = new FileInputStream(dir);
  26. builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  27. doc = builder.parse(fi);
  28.  
  29. NodeList nlorgid = doc.getElementsByTagName("Organization");
  30. String orgidfromxml = ((Element)nlorgid.item(0)).getAttribute("id");
  31. System.out.println(" organization id from xml is "+orgidfromxml);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement