Guest User

Untitled

a guest
May 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. public void search()
  2.     {
  3.         NodeList nl = doc.getElementsByTagName("LKW");
  4.         int gewicht;
  5.        
  6.         for(int i = 0; i < nl.getLength(); i++)
  7.         {
  8.             gewicht = Integer.parseInt(nl.item(i).getAttributes().getNamedItem("Zuladung").getNodeValue());
  9.            
  10.             if(gewicht >= 8000)
  11.             {
  12.                 System.out.println(nl.item(i).getChildNodes().item(1).getAttributes().getNamedItem("Leistung").getNodeValue());
  13.             }
  14.         }
  15.     }
  16.    
  17.     public void search2()
  18.     {
  19.         NodeList nl = doc.getElementsByTagName("LKW");
  20.         int gewicht;
  21.         Element lkw, motor;
  22.        
  23.         for(int i = 0; i < nl.getLength(); i++)
  24.         {
  25.             lkw = (Element) nl.item(i);
  26.            
  27.             gewicht = Integer.parseInt(lkw.getAttribute("Zuladung"));
  28.            
  29.             if(gewicht >= 8000)
  30.             {
  31.                 motor = (Element) lkw.getElementsByTagName("Motor").item(0);
  32.                
  33.                 System.out.println(motor.getAttribute("Leistung"));
  34.             }
  35.         }
  36.     }
Add Comment
Please, Sign In to add comment