1 Reply Latest reply: May 20, 2011 6:12 AM by 802033 RSS

    xml in midp

    862470
      Hi All

      Probably a daft question but hopefully not .

      I have an xml file located with in a package and am trying to parse it. code...
      try{
      ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes());
      }
      // obtain a SAX parser
      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser parser;
      parser = factory.newSAXParser();
      try {

      parser.parse(in, new DefaultHandler() {

      but gets parseexception error on last line ( parser.parse(in, ). I suspect that the program cant find the file. Does anyone know a way of getting to an xml file from a package??
        • 1. Re: xml in midp
          802033
          Hello.

          What is the xml property?
          If the XML is in your .jar file, why not to use Class.getResourceAsStream method to open direc stream?

          Anyway in case of mising file I'd say you probably get different error.
          There might be simply an error in the XML... the parser expectes well formated XML. It doesn't parse wrong file. You can check the XML validity on some free internet web page tools.

          Rada