×

Discussion Board

Results 1 to 5 of 5

Thread: kXML 2 problem

Hybrid View

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    5

    kXML 2 problem

    I return an InputStream from an InputConnection.
    Then I create an instance of kXMLParser and use the use the setInput function and pass the InputStream to it.

    But as soon as I call one of the parsers of function like .next() it just hangs. It is as if it doesnt read the XML.

    Here is my code:
    inConn = (InputConnection)Connector.open (getURL,Connector.READ,false);
    inStream = inConn.openInputStream();

    KXmlParser parser = new KXmlParser();
    parser.setInput(new InputStreamReader(inStream));

    int eventType = KXmlParser.START_TAG;
    while (eventType != KXmlParser.END_DOCUMENT) {
    eventType = parser.next();
    System.out.println(parser.getName());
    }

    What am I doing wrong?
    Please help!!

    Mark

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    9
    Have you tried....

    int eventType = parser.getEventType();

    do {
    if (eventType == parser.START_DOCUMENT) {
    ;
    } else if (eventType == parser.END_DOCUMENT) {
    ;
    } else if (eventType == parser.START_TAG) {
    .......
    } else if (eventType == parser.END_TAG) {
    ........
    } else if (eventType == parser.TEXT) {
    .........
    }
    eventType = parser.next();
    } while (eventType != parser.END_DOCUMENT);

    Phil Miller

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    184
    I'm quite new to the XML field in J2ME, and I wonder if kXMLParser is an existing API or code you wrote by yourself?
    Thanks in advance

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

  5. #5
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    184
    Many thanks.
    Is there also open source package for XML browser for J2ME

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×