Java tutorial
//package com.java2s; import android.util.Log; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import java.util.ArrayList; public class Main { private static final String TAG = "NWhelper"; /** * Sarches for ressources that have to be downloaded and creates a list with all download links. * * @param node to check for download links * @return list with all found download links */ private static ArrayList<String> findUrls(Node node) { int type = node.getNodeType(); ArrayList<String> result = new ArrayList<>(); String temp = null; NamedNodeMap atts = node.getAttributes(); Log.i(TAG, "parsing for ressources. node: " + node.getNodeName() + " value: " + node.getNodeValue() + " atts length: " + atts.getLength() + "type: " + type); switch (type) { //Element case Node.ELEMENT_NODE: //TODO: This method is stupid. It just looks for // attributes named ressourcepath. What if we have to download several ressources? for (int j = 0; j < atts.getLength(); j++) { Log.i(TAG, "atts: " + atts.item(j).getNodeName() + " value: " + atts.item(j).getNodeValue()); temp = atts.item(j).getNodeValue(); if (temp != null) { result.add(temp); Log.i(TAG, "added path: " + temp); } Log.i(TAG, "parent node:" + node.getParentNode().getNodeName()); Element parent = (Element) node.getParentNode(); parent.setAttribute("TESTITEST", "dllink"); } // get the pages, means the children for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { ArrayList<String> childres = findUrls(child); if (childres.size() > 0) { result.addAll(childres); } } break; } return result; } }