I am making an application that needs to get an XML file from a URL and parse it. I always find this log cat (PS: I cannot find the correct sintax code highlighting for google prettify):
11-06 23:12:44.940: E/Trace(8751): error opening trace file: No such file or directory(2) 11-06 23:12:51.345: E/Error:(8751): expected: /hr read: body (position:END_TAG </body>@6:8 in java.io.StringReader@431887b8 ) 11-06 23:12:51.360: E/AndroidRuntime(8751): FATAL EXCEPTION: AsyncTask
xml can be found at: http://www.lookedpath.tk/apps/firstapp/version.xml
code update.java:
public class Update extends Activity { private TextView testo2; @Override public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.update); super.onCreate(savedInstanceState); testo2= (TextView) findViewById(R.id.textView2); } public void goToUpdate (View view) { System.out.println("ciao"); new connection().execute(); } public class connection extends AsyncTask<Void, Void, Boolean> { protected Boolean doInBackground(Void... params) { boolean updated=false; String lastversion=null; Element e=null; final String URL = "http://www.lookedpath.tk/apps/firstapp/version.xml"; final String VERSION = "version"; final String APPLICATION = "application"; XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(URL);
so this is the xmlparser.java file:
public class XMLParser { public String getXmlFromUrl(String url) { String xml = null; try {
logcat says the error is on line 39 of the update class:
NodeList nl = doc.getElementsByTagName(APPLICATION);
but I can not solve the problem. can someone help me?
UPDATE: I fixed error 405, but I still have a null pointer exception. I found that the program is working correctly, but never introduces the post post method due to this exception.
source share