SAX parse online xml problem

Discussion in 'Java' started by iherage@gmail.com, Jan 23, 2008.

  1. Guest

    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!
     
    , Jan 23, 2008
    #1
    1. Advertising

  2. Arne Vajhøj Guest

    wrote:
    > 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
     
    Arne Vajhøj, Jan 24, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. curwen

    sax xmlreader.parse problem

    curwen, Nov 10, 2003, in forum: Java
    Replies:
    4
    Views:
    3,202
    curwen
    Nov 11, 2003
  2. Replies:
    4
    Views:
    4,386
  3. Debajit Adhikary
    Replies:
    0
    Views:
    264
    Debajit Adhikary
    May 18, 2007
  4. goldtech

    SAX XML Parse Python error message

    goldtech, Jul 13, 2008, in forum: Python
    Replies:
    5
    Views:
    325
    Fredrik Lundh
    Jul 15, 2008
  5. Erik Wasser
    Replies:
    5
    Views:
    498
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page