Android XML解析器不工作
我正在编写一个带有XML解析器的android应用程序。 我有一个解析器,它过去可以工作,但当我运行它时,它什么也不做。 这是我的班级:Android XML解析器不工作,android,xml,parsing,Android,Xml,Parsing,我正在编写一个带有XML解析器的android应用程序。 我有一个解析器,它过去可以工作,但当我运行它时,它什么也不做。 这是我的班级: import java.net.URL; 导入javax.xml.parsers.DocumentBuilder; 导入javax.xml.parsers.DocumentBuilderFactory; 导入org.w3c.dom.Document; 导入org.w3c.dom.Element; 导入org.w3c.dom.Node; 导入org.w3c.do
import java.net.URL;
导入javax.xml.parsers.DocumentBuilder;
导入javax.xml.parsers.DocumentBuilderFactory;
导入org.w3c.dom.Document;
导入org.w3c.dom.Element;
导入org.w3c.dom.Node;
导入org.w3c.dom.NodeList;
导入org.xml.sax.InputSource;
导入android.app.Activity;
导入android.os.Bundle;
导入android.widget.LinearLayout;
导入android.widget.TextView;
导入android.widget.Toast;
公共类XmlParsingsingDomeActivity扩展活动{
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
LinearLayout布局=新的LinearLayout(本);
布局。设置方向(1);
TextView ID[];
TextView vraag[];
文本视图类别[];
TextView a1[];
TextView p1[];
TextView a2[];
TextView p2[];
TextView a3[];
TextView p3[];
试一试{
URL=新URL(
"http://128.140.217.126/vragen.xml");
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder dbu=dbf.newDocumentBuilder();
Document doc=dbu.parse(新的输入源(url.openStream());
doc.getDocumentElement().normalize();
NodeList NodeList=doc.getElementsByTagName(“项目”);
ID=newtextView[nodeList.getLength()];
vraag=新文本视图[nodeList.getLength()];
category=newtextView[nodeList.getLength()];
a1=新的文本视图[nodeList.getLength()];
p1=新文本视图[nodeList.getLength()];
a2=新的文本视图[nodeList.getLength()];
p2=新的文本视图[nodeList.getLength()];
a3=新的文本视图[nodeList.getLength()];
p3=新文本视图[nodeList.getLength()];
for(int i=0;i
还有我的舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.pace.namace"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".XMLParsingUsingDomeActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
而logcat输出是毫无价值的。
我没有更改代码,只是不再工作。有什么例外
可能会发生两件事。可能是在您尝试从web服务获取URL时。可能是因为您必须在异步任务中执行代码。
我建议您右键单击怀疑的行并切换断点,然后在包资源管理器中的类上右键单击它并转到“调试为”,然后转到“调试配置”。检查是否正在调试正确的项目后,单击“调试”按钮
欢迎使用调试模式,只需尝试查看导致异常的行