Discussion Board

Results 1 to 2 of 2

Thread: XML Problem

  1. #1
    Registered User
    Join Date
    Jun 2007

    XML Problem

    hi there!

    I'm using kXML as Lib for parsing XML.
    KXmlParser parser = new KXmlParser();	
    				InputStream is = getClass().getResourceAsStream("/vok.vok2");
    				parser.setInput(new InputStreamReader(is));	
    				parser.require(XmlPullParser.START_TAG, null, "teachmaster");
    				while (parser.nextTag () != XmlPullParser.END_TAG)
    						parser.require(XmlPullParser.START_TAG, null, null);
    						while (parser.nextTag() != XmlPullParser.END_TAG) 
    							parser.require(XmlPullParser.START_TAG, null, null);
    							String name = parser.getName();
    							parser.require(XmlPullParser.END_TAG, null, name);
    						parser.require(XmlPullParser.END_TAG, null, null);
    				parser.require(XmlPullParser.END_TAG, null, "teachmaster");
    				parser.require(XmlPullParser.END_DOCUMENT, null, null);
    the XML looks like this:

    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
          <bemerkungen>ein test</bemerkungen>
    the error is:

    org.xmlpull.v1.XmlPullParserException: expected: END_TAG {null}titel (position:START_TAG <titel>@4:14 in java.io.InputStreamReader@1cb37664) 
    	at org.kxml2.io.KXmlParser.exception(+47)
    	at org.kxml2.io.KXmlParser.require(+83)
    	at mobilelearn$ReadXML.run(+95)

    i would be cool if someone has a hint fo me


  2. #2
    Regular Contributor
    Join Date
    Aug 2006

    Re: XML Problem

    I guess the problem is that you've setted up parser for any starting tag parser.require(XmlPullParser.START_TAG, null, null); just after you've meet the "header" tag.

    It would be much easier and simpler if you would use the states indicating that you're inside the "header" block, and then simply check for values:

    boolean insideHeader = false;
    String currentName = "";
    while (parser.nextTag () != XmlPullParser.END_TAG) {
        currentName = parser.getName();
        if (currentName.equals("header")) {
            insideHeader = true;
        else if (insideHeader) {
            if (currentName.equals("titel")) {
                // get data etc...
    Last edited by axs; 2007-06-15 at 07:28.

Similar Threads

  1. Parsing wbxml file to xml file using kxml parser
    By ramyashashe in forum Mobile Java General
    Replies: 18
    Last Post: 2010-05-17, 15:56
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. XML parsing problem in Nokia 12
    By codekiller in forum Nokia M2M
    Replies: 2
    Last Post: 2005-04-26, 09:01
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36
  5. 7210 Silent Problem
    By MarkMckim in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-18, 12:36

Posting Permissions

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