伙计们我在URL中有一个xml,我需要解析那个xml
下面的是我的xml
这就是我解析的方式
InputStream in = new FileInputStream(file);
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = builder.parse(in, null);
NodeList audio = doc.getElementsByTagName("point");
int len = audio.getLength();
Toast t = Toast.makeText(getApplicationContext(), "Length is "+len, 0);
t.show();
for (int i = 0; i < len; i++) {
Node singleTerminalNode1 = audio.item(i);
Element secondlevel = (Element)singleTerminalNode1;
NodeList value2Nodes = (secondlevel).getElementsByTagName("file");
String audioxml = ((Element)value2Nodes.item(0)).getAttribute("name");
System.out.println("got the value from audioxml "+audioxml);
Toast toast = Toast.makeText(getApplicationContext(), "Downloaded to Sdcard/varun/"+audioxml, 0);
toast.show();
}
但是我需要从URL解析如何使这个
答案 0 :(得分:1)
URL url;
url = new URL("http://.....");
URLConnection ucon = url.openConnection();
ucon.connect();
url.openStream()
url.openStream()
返回一个InputStream。所以用你的new FileInputStream(file);
替换它应该没问题。