SAX parse online xml problem

I

iherage

I have this java applet parse the xml file
the xml is online:
like https://localhost:800/.../filename.xml
The part of the code is
try {
SAXParserFactory sf = SAXParserFactory.newInstance();
SAXParser sp = sf.newSAXParser();
XMLReader xmlReader = sp.getXMLReader();
xmlReader.setContentHandler(this);
InputSource source = new InputSource(fileName);
xmlReader.parse(source);
} catch (Exception e) {
e.printStackTrace();
}

it works well when the xml file is on my computer, but i cannot have
to it work for the online xml(on the server).

The error message is

java.io.FileNotFoundException: https:/localhost:800/.../filename.xml
(No such file or directory)

Does anyone know how to solve this? thanks!
 
A

Arne Vajhøj

I have this java applet parse the xml file
the xml is online:
like https://localhost:800/.../filename.xml
The part of the code is
try {
SAXParserFactory sf = SAXParserFactory.newInstance();
SAXParser sp = sf.newSAXParser();
XMLReader xmlReader = sp.getXMLReader();
xmlReader.setContentHandler(this);
InputSource source = new InputSource(fileName);
xmlReader.parse(source);
} catch (Exception e) {
e.printStackTrace();
}

it works well when the xml file is on my computer, but i cannot have
to it work for the online xml(on the server).

The error message is

java.io.FileNotFoundException: https:/localhost:800/.../filename.xml
(No such file or directory)

Does anyone know how to solve this? thanks!

Try:

InputSource source = new InputSource((new URL(url)).openStream());

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top