Xml in midp

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??

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

Similar Messages

  • XML and MIDP

    Are there any easy to understand tutorials that just show how you connect to a server through Http, query the database and generate an XML file so that MIDP displays it ??
    I already have the database connection stuff working and http it's just that i don't understand the XML part.

    http://developers.sun.com/techtopics/mobility/midp/articles/parsingxml/index.html
    http://www.ericgiguere.com/nanoxml/index.html
    I use the ported NanoXML as a model parser. I find XParseJ too slow, especially on larger XML files.
    Next up you want to use 'astrientlabs.com' LineEnumeration:
    http://fotomica.astrientlabs.com/downloads/textwrap.jsp
    The rest is up to you. Cut and paste some code if you are having problems.

  • Writing xml file, midp, kxml - any ideas?

    Hello,
    Does any have sample code of writing an XML file with kXML or a similar tool?
    I'm getting confused with OutputWriter being abstract/DataOutputWriters not working.
    My code as follows is fairly non-existent..
    OutputStream out = "test.xml"; // this errors with incompatible type (obviously) but what needs to go here?
    XmlWriter fxml = new XmlWriter(out);
    thanks in advance
    poncenby

    OutputStream out = "test.xml"this cant work. the latter is a string and the former an OutputStream.
    yeah, thats pretty strange with the input and output of kXML. What you have to do is:
    1) write a class, that extends the java.io.OutputStream. To do this, you have to implement all abstract methods of this (afaik write(byte))
    2) this class can you pass to the XmlWriter. The most simple way of writing the bytes is to append it to a string, which you reference afterwards.
    public class MyOutputStream extends OutputStream
    public String output = "";
    public void write(int b)
      output += (char)b;
    }then write the stuff out and get the output of your OutputStream class. For writing this to a file (whichis not possible with J2ME, you have to some file handling in your OutputStream, like opening, appending and closing)
    Note: this works only, if the content consists of characters. If you want to write binary data, this will get corrupt, since the cast to char transforms this binaries to characters. The reverse is (afaik) not possible.
    hth
    Kay

  • XML parser in MIDP

    I have some problems in building an XML parser in MIDP. I used the
    J2ME wireless Toolkit from sun. After I have created the project, I
    copy the kxml sources (starting with the "org" directory) to
    <project>\src. Then I click on the Build button. It said that package
    org.kxml does not exist. But I have this code"import org.kxml.*" in
    my program. Can anyone help me? Thanks a lot.

    I had the same problem too. Even I followed the instruction of the article "XML AND JAVA[TM] LANGUAGE PROGRAMMING FOR WIRELESS DEVICES: A TUTORIAL" http://www.sun.com/developers/evangcentral/totallytech/j2me.html
    I put org package (unzip kxml2.zip) under <myproject>/classes, the toolkit (wtk104) still can not find the parser. I also tried to put org package under apps/lib, still got same problem. Please help.
    Any input will be greatly appreciated.

  • Problem parsing xml(J2ME Web Service spec) containing image in cldc/midp

    Hi,
    I have created a restful web service that generates xml file in app server. I have created xml file using JAXB2.1 spec. This xml file has many elements starting from char data to image (binary data). I could successfully create xml file and developed another test client to read the same file using JAXB. However, I am finding a problem while getting the image in the java me client (cldc1.1 and midp2.0).
    I am using J2ME Web Services Specification, using javax.xml.parsers.SAXParser to parse the xml file. Parsing is successful and got the character data. But the image data is not accurate, so I am not getting the image. I suspect the problem is with encoding but not sure how to solve this. At the server end, I verified that xml file is encoded with "UTF-8" encoding, not sure how to decode at the client end.
    I am totally confused as how to get the accurate image data, not sure if I use kxml parser would solve my problem.
    I would really appreciate if somebody can get back to me as this is very very important.

    Try to send to your web service the byte array instead of string and then convert the byte array into an image
    using a method like the following one in your service:
    // C# code
    public Image ByteArrayToImage(byte[] byteArrayIn)
         MemoryStream ms = new MemoryStream(byteArrayIn);
         Image returnImage = Image.FromStream(ms);
         return returnImage;
    }There can be some problem between encoding in J2ME and .Net so try different encodings in gathering the image bytes in your j2ME application, but, instead of jpg which has more encodings, try png that is a more standardized image compression(open standard).

  • How to open xml file in MIDP?

    Hi,
    I want to open xml file which stored localally, for reading and writing operation.
    Is it possible to open file in J2ME, if not possible is any other way to handle file operation. please guide me.
    Note: I want to open file which stored locally.

    You may check these tips:
    How to Access Local File Systems from J2ME devices using FileConnection API
    http://www.java-tips.org/content/view/109/73/
    Opening and reading a file on the mobile device
    http://www.java-tips.org/content/view/352/73/

  • Java XML parsers for Sun J2ME, Sun KVM

    Here is a list of "small" XML parsers.
    Some are specifically for the J2ME platform / Sun KVM:
    kXML
    http://kxml.enhydra.org/
    NanoXML
    http://nanoxml.sourceforge.net/
    TinyXML
    http://www.gibaradunn.srac.org/tiny/index.shtml
    MinML
    http://www.wilson.co.uk/xml/minml.htm
    XMLtp
    http://sourceforge.net/projects/jxmltp/
    Al Sutton XML parser
    http://sourceforge.net/projects/asxmlp/
    Also:
    JSR 118 is a specification for the "Mobile Information Device
    Next Generation"
    http://www.jcp.org/jsr/detail/118.jsp
    The JSR 118 group is considering adding a "small, efficient XML parser to enable platform-independent data exchange" to MIDP.

    Fastparser is a 25Ko parser : http://www.japisoft.com/fastparser
    Best regards,
    A.Brillant

  • Write XML to file - character set problem

    I have a package that generates XML from relational data using SQLX. I want to write the resulting XML to the unix file system. I can do this with the following code :
    DECLARE
    v_xml xmltype;
    doc dbms_xmldom.DOMDocument;
    BEGIN
    v_xml := create_my_xml; -- returns an XMLType value
    doc := dbms_xmldom.newDOMDocument(v_xml);
    dbms_xmldom.writeToFILE(doc, '/mydirectory/myfile.xml');
    END;
    This creates the file but characters such å,ä and ö are getting 'corrupted' and the resultant xml is invalid.(I've checked the xml within SQL*Plus and the characters are OK)
    I assume the character set of the unix operating system doesn't support these characters. How can I overcome this ?

    Hi,
    Do you mean that you would like to write output to an external file somewhere on flask disk or perhaps even inside the directory where the MIDlet is located?? To be able to do so you will need manufacturere specific APIs extended on FileConnection (=JSR, don't know the number right now...). The default MIDP I/O libary does not support direct action on a file.
    However, such a FileConnection method invocation requires an import statement that is manufacturere specifc...
    To keep your MIDlet CLDC MIDP compliant you can try using RMS with which you can write data that will be stored in a 'database' within the 'res' directory inside your MIDlet suite. If you're new to RMS, please check the web for tutorials, etc etc.
    Cheers for now,
    Jasper

  • Xml Push Parsing in J2Me applications

    Hi all,
    I would like to use Push parser in j2me application.Can u please tell me how can i use sax parser in mobile application.Because when i included "jaxp-api.jar" in mobile application,it gives an error "FactoryFinder class not found".. So please tell me how can i overcome this error or any other push parser available for J2me applications.
    Thanks
    Regards
    Sourab

    Please review this article.
    http://developers.sun.com/techtopics/mobility/midp/articles/parsingxml/
    There is a link to a push parser mid way through the article. If you search "push parser j2me" you should be able to find others.
    If you still are not able to find a push parser you could create your own. How complex is the xml you need to parse?
    I created an example called y!p! some time ago that uses a push parser to parse Yahoo's Image Search web service. (http://developer.yahoo.com/search/image/V1/imageSearch.html)
    You can download the example src code. For a more complex example you could look at w!k!. It uses a push parser to parse html wikipedia articles.
    w!k! push parser src:
    http://hostj2me.cliqcafe.com/www/forumtopicview.html?fid=58&categoryId=36&fpn=0
    w!k! src code:
    http://www.hostj2me.com/appdetails.html?id=1569

  • Building XML dynamically? Is it possible.

    How do I build an XML Document dynamically.?
    I am wrting MIDP Applications (applications for the Mobile
    device) and I am required to send requests to the server
    in XML Formats.I have multiple requests to be sent to the
    server in XML and then I receive XML responses from the server
    which i need to parse.
    Now,if I store all the required requests in a Class,that are needed to be sent to the server,I am taking a lot of space of the cell phone.
    How can I create an XML string dynamically that is sent to the
    server as and when required.
    Please can any one respond?
    AJAY
    ajay [email protected]

    Hi there,
    So is it possible for me to create an XM file on the fly.?
    For example: I need to send an xml file to the server
    For this I have a class called RequestHandler having a method called
    sendRequest1(),sendRequest2(),sendRequest3() etc etc
    public class Request{
    public void sendRequest()
    String req1 = "<xml.........>
    public void sendRequest2()
    req2 = "<xml......>";
    public void sendRequest3()
    req3 = "<xml...>";
    This way I have a lot of xml file format in each method.
    Please explain as to how I can create the XML file required
    to be sent for each request to the server on the fly.
    Storing this class with all the XML file formats takes up a lot
    of space on the MIDP device...
    Thanks for yr response.
    Ajay

  • J2ME and XML - sync XML to PalmOS?

    I'd like to build a PalmOS MIDP/CDLC app (along with nanoXML or the like) that, on sync, hits a server looking for newer versions of an XML file. If it finds one, it downloads it to the device (or perhaps does some processing via XSLT first and then sends it).
    I've already built a successful PalmOS MIDP/CDLC app with nanoXML, packaging the XML in the .prc, but I'd like to know if it's possible to do the scenario I've described above and, if so, how I'd go about it.
    Thanks very much for your assistance!
    Steve Spadt
    [email protected]

    You probably want to use a standard called syncML which is designed to do exactly that.
    If you go to http://www.syncML.org and have a look there are some documents on it and then a list of products that support it. There are some that you can pay lots of money for, or there are some free open source ones. take your pick.
    Cheers,
    Peter.

  • Where I can Find AelFred XML Parser for J2ME?

    Hi,
    I need the Aelfred XML SAXParser to run MIDP applications.
    The actual url is www.microstar.com
    but the site is not avialable.
    If any body has an idea about the new URL? or if u have the aelfred parser kit for the J2ME API, then please send it back to
    [email protected]
    Thanks
    Eldo.

    The AElfred project has been merged with the GNU JAXP project:
    http://www.gnu.org/software/classpathx/jaxp/jaxp.html
    There, you have a link to the FTP mirror sites..
    GNU JAXP includes the �lfred2 SAX2 parser.

  • S60 3rd Edition MIDP + Netbeans 5.5 + Mobility CLDC !URGENT!

    My Environment       Device: Nokia E61
           SDK: S60 3.0 MIDP SDK (S60 3rd Ed MIDP)
           Java: javac 1.5.0_12
           OS: Microsoft Windows XP Professional [Version 5.1.2600]/ Service Pack 2
           Computer: AMD Athlon 64bit CPU 3200+ 2.1GHz, 1.00GB Mem
           NetBeans (5.5 dev build ):
              Number: 200704122300
              Date: ${buildday}
              Branding:
              Branch: release551
              Tag:
           Mobility: NetBeans Mobility Pack 5.5.1I am having problems building application with netbeans. The jar file is coming out excessively large and it fails to run on the emu, get -10504 error (already tried to lookup error code at http://newlc.com/Symbian-OS-Error-Codes.html and it is not listed there). I inspected the .jar file and did not see anything there that did not belong; only .class, .png, kxml library and manifest files were present (no Thumbs.db or other clutter).
    When I build the same application with CarbideJ the jar file size is significantly smaller and it executes on the Emulator. Are any of the CarbideJ tasks, namely <ndsj2mejavac> and/or <ndsj2mepackage>, doing something special to source, jar or images that maybe netbeans is skipping; running a different preverifier, different archiver, using it's on version of javac.exe or something?
    When I compile using Carbide.j this is what I get (NO obfuscated/NO debug info);
         AppXXX.jad (400 bytes)
         AppXXX.jar (728,538 bytes)however, when I compile with Netbeans, I get the following(obfuscated set to level 9/NO debug info);
         AppXXX.jad (471 bytes)
         AppXXX.jar (927,530 bytes)The jad files generated were different but only because one had more descriptor tags in it, nothing major about that. The problem is that the jar file generated by netbeans is significantly larger than the one generated by carbide. Also, I compiled the exact same program under the Sun Wireless toolkit v2.5.1 and got the exact same jar file sizes and runtime error on emu that netbeans generated; I installed s60 sdk for wtk and selected it before before creating package for application. Also I state before, the version created with Carbide.j runs in the Emu; however, the NB version does not.
    Already posted to Nokia forum and no help there
    I would be very appreciative if I can quickly get some help!
    Files:
    build.xml (output of netbeans build process is append to the end of the build file in an xml comment): http://home.comcast.net/~eramsey1535/JavaME/Nokia/build.xml
    CFG_DEV.properties: http://home.comcast.net/~eramsey1535/JavaME/Nokia/CFG_DEV.properties.txt
    project.properties: http://home.comcast.net/~eramsey1535/JavaME/Nokia/project.properties.txt
    image of error displayed on emu: http://home.comcast.net/~eramsey1535/JavaME/Nokia/error_displayed_on_emu.gif
    image of error in emu popup dialog: http://home.comcast.net/~eramsey1535/JavaME/Nokia/error_displayed_in_emu_popup_dialog.gif
    Thanks!

    Hi,
    I'm facing exactly the same problem, and was wondering whether you found the solution to this problem.
    Thanks in adance,
    Iwan

  • Parsing the xml data

    Hi,
    i have the mehtods in proxy class. those methods are return the data as string. and all the data is in an XML format. now i want to parse that data to normal doc and convert into string form. give me the solution.
    Thanks

    sailesh is right! kXML is very popular pasrer for J2ME apps.
    Its pull type parser, 3 main things about kXML
    1. Reads a little bit of a document at once.
    2. Parser goes through the document by repeatedly requesting the next piece.
    3. Best suitable for J2ME application as take comparatively less memory and processing than other type of parser.
    For resource-constrained devices following parsers are frequently used -
    1. kXML
    Written exclusively for the J2ME platform (CLDC and MIDP).
    http://kxml.objectweb.org/software/downloads/
    2. NanoXML
    Version 1.6.8 for MIDP, supports DOM parsing.
    http://nanoxml.cyberelf.be/download.html
    I have used kXML and found it the best!
    Regards,
    Rohan Chandane

  • Problem about midp porting

    Hi,
    I port midp currently and I encounter one problem.
    all tools and midp.exe is ok(my platform is win 2k).
    but when I run midp.exe, the main window can display.
    but cannot work. when I debug the code, i found that
    midp cannot found com.sun.midp.main.Main.
    I am confuse now because the ROMizer step is ok
    and ROMjavaWin.c is genrated also.
    who can help me to solve this problem?

    It works now.
    I have updated web.xml to below:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4">
      <servlet>
        <servlet-name>controller</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    </web-app>

Maybe you are looking for

  • Setting System Date for the Deadline branch of a block

    Hi, We have a IDocs->XI->File scenario. We need to collect the idocs coming from ISU system and do a N:1 mapping into a single file. We need to end the collection process everyday at a particular time... In ABAP workflows if we are using a block for

  • I pod classic (old school) wont turn on

    ok here's the deal, i turned on my old i pod it's a 20 gig click wheel no color screen. i wanna fix it because i need an i pod with a lot of space and my i touch is full. so was goign touse my old i pod to put music. now i turn it on and it brings up

  • "The Pure Networks Platform Service Is Not Running" every time I print

    I will be glad to follow-up with all the gory details about my system, but I thought I'd throw out a general question first.  I just installed a network printer to my NM Network.  It's a Lexmark 543dn connected via ethernet.  Everything prints just f

  • Pricing in CRM

    Hi All, What is the difference between Pricing in CRM 2007 and Pricing in CRM 5.0? Thanks Sonali

  • Bug fixing and enhancements in reports

    can u please provide me the belo mentioned object     changes in budget variance report, added a new functionality by displaying the report in treeformat when user inputs fsv