Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package iterator;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import javax.xml.parsers.DocumentBuilder;
  7. import javax.xml.parsers.DocumentBuilderFactory;
  8. import javax.xml.parsers.ParserConfigurationException;
  9. import javax.xml.soap.Node;
  10. import javax.xml.transform.TransformerException;
  11.  
  12. import org.w3c.dom.Document;
  13. import org.w3c.dom.NodeList;
  14. import org.xml.sax.SAXException;
  15.  
  16. public class iterator {
  17.  
  18. public static void main(String[] args) throws SAXException, IOException,
  19. ParserConfigurationException, TransformerException {
  20. DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
  21. .newInstance();
  22. DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
  23. Document document = docBuilder.parse(new File("assets.minecraft.net.xml"));
  24.  
  25. NodeList nodeList = document.getElementsByTagName("*");
  26. for (int i = 0; i <nodeList.getLength(); i++) {
  27. org.w3c.dom.Node node = nodeList.item(i);
  28. if (node.getNodeType() == Node.ELEMENT_NODE) {
  29. // do something with the current element
  30. System.out.println(node.getNodeName());
  31. }
  32. }
  33. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement