Hi all,

Before I detail my error/problem, let me thank all the help from the
community in advance.

I'm trying to parse a XML from a page/URI the DocumentBuilder method
parse(String uri) - reference here
http://developer.android.com/reference/javax/xml/parsers/DocumentBuilder.html
- but on run-time it gives me a SAXParseException: InputSource needs
either stream or reader.

The code I'm using inside the method onCreate of the class
pt.pelicula.Pelicula is:

try {
        DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document xmldata = builder.parse("http://services.sapo.pt/GIS/
GetDistrictsSortedByName?includeMunicipalities=false"); // This is
line 120.
} catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
} catch (FactoryConfigurationError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
}

The on the logcat the exception is:

W/System.err(  785): org.xml.sax.SAXParseException: InputSource needs
either stream or reader
W/System.err(  785):    at
org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:
124)
W/System.err(  785):    at
javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:201)
W/System.err(  785):    at pt.pelicula.Pelicula.onCreate(Pelicula.java:
120)
W/System.err(  785):    at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
W/System.err(  785):    at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
W/System.err(  785):    at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
W/System.err(  785):    at android.app.ActivityThread.access
$1800(ActivityThread.java:112)
W/System.err(  785):    at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1692)
W/System.err(  785):    at
android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  785):    at android.os.Looper.loop(Looper.java:123)
W/System.err(  785):    at
android.app.ActivityThread.main(ActivityThread.java:3948)
W/System.err(  785):    at java.lang.reflect.Method.invokeNative(Native
Method)
W/System.err(  785):    at java.lang.reflect.Method.invoke(Method.java:
521)
W/System.err(  785):    at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
W/System.err(  785):    at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
W/System.err(  785):    at dalvik.system.NativeStart.main(Native Method)

Did someone had problems with XML parsing from an URI before?

I think the compiler is using the parse(InputSource source) abstract
method (http://developer.android.com/reference/javax/xml/parsers/
DocumentBuilder.html#parse%28org.xml.sax.InputSource%29) instead of
the parse(String uri) one (http://developer.android.com/reference/
javax/xml/parsers/DocumentBuilder.html#parse%28java.lang.String%29).
But why?

Can anyone shed some light on this one? I would be much appreciated.

I'm using API from the version 1.5 of the Android, API Level 3.

Thanks in advance again.

--
Pedro Machado Santa

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to