parsing xml in blackberry jde 5.0

Hi, I was wondering if someone could help me to analyze an XML file from a server in the channels that I can use. I'm trying to access the data are under the "ResponseChoices" tag in the following fragment:

It is a question, nothing to do with the BlackBerry in particular generic analysis of XML. Your code does not work because it is not navigate the DOM correctly. For the XML file that you posted, x.item (0) is an element corresponding to the tag. This element has two child elements corresponding to the tags. (It can have children for the white spaces as well, depending on the configuration of the parser, it is better to browse children or reuse getElementsByTagName.) The child element for each tag has, in turn, a child of text that contains the value you want.

So maybe a way to do this:

NodeList x = messageElements[i].getElementsByTagName("String");
int n = x.length();
String[] choices = new String[n];
for (int i = 0; i < n; ++i) {
    choices[i] = x.item(i).getFirstChild().getNodeValue();
}

If you have tags in other places, so you can first get each ResponseChoices node, cast to an element and call the getElementsByTagName method to obtain that these tags that fall under it.

Tags: BlackBerry Developers

Similar Questions

  • What happens to parsing xml?

    Hello

    I haven't checked the front for bb xml parsers and now I need to analyze a simple file, smth like:

    
    
      
      
      
      
    
    

    So, it's pretty simple. can anyone suggest me which library should I use and what start?

    concerning

    Hello, you need to use DocumentBuilderFactory:

    public class XmlReader {
    
      private static String XML_FILE = "your/xml/file/name.xml";
    
      public XmlReader() {     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();    DocumentBuilder builder = factory.newDocumentBuilder();    InputStream inputStream = getClass().getResourceAsStream( XML_FILE);    Document document = builder.parse( inputStream );
    
        Element rootElement = document.getDocumentElement();    rootElement.normalize();
    
        Object yourObject = parse(rootElement);  }   ...  private Object parse(Node node) {....} }
    

    in the parse method (node), you use node.getChildNodes () to travel through the child of the node and create your object of the desired type, or you can view the items on the screen... This is only a sample of shortcuts, you should really look into the Blackberry JDE samples, xmldemo, located in \samples\com\rim\samples\device\xmldemo in the home directory of BlackBerry, there is nothing difficult

  • Problem in parsing XML

    Hello

    Any1 can you please tell me how to do Xml parsing in Blackberry. I'm a bit confused by it.

    Assume that it is my link:

    {keyword: "keword", url: "videoUrl"}

    While parsing xml:

    String keyword1 ="";

    element.getName.equalsIgnoreCase ("keyword");

    keyword1 = Element.GetText ();

    is she writing?

    Hey its done.

  • Impossible to download Blackberry JDE

    Hello

    I am trying to download Blackberry JDE v4.5 for these last two days, but after downloading about 14Mo, Server error is coming. Same is the case with my friend who is also trying to download Blackberry JDE. Is there a problem with the server?

    Thanks for your reply. Waiting for the issue to be decided.

  • How to write a program that allows an HTTPs connection to the APACHE TOMCAT server in blackberry JDE

    Hello.. I am very new to the blackberry JDE environment. But then, I have a project in which I should write a program that will make an HTTPs connection to the apache tomcat server using blackberry JDE. The simulator which I use is 8330-JDE.

    Here is my code...

    import java.io.IOException;

    Import java.io.InputStream;

    Import javax.microedition.io.Connector;

    Import javax.microedition.io.HttpsConnection;

    Import net.rim.device.api.ui.UiApplication;

    Import net.rim.device.api.ui.container.MainScreen;

    public class Httproto extends UiApplication

    {

    public public static void main (String [] args)

    {

    Httproto instance = new Httproto();

    instance.enterEventDispatcher ();

    }

    public Httproto()

    {

    pushScreen (new HttpsConnectionScreen());

    }

    }

    final class HttpsConnectionScreen extends screen

    {

    public HttpsConnectionScreen()

    {

    HttpsConnection c = null;

    InputStream is = null;

    int rc;

    try {String url =

    "https://192.168.2.3: 8443/cit/j_acegi_security_check? j_username = sanogo & j_password = redhat;

    c = (HttpsConnection) Connector.open (url);

    c.setRequestMethod (HttpsConnection.POST);

    System.out.println ("connection is open with the server");

    Get the response code is open the connection,

    Send the request and read HTTP response headers.

    The headers are stored until asked.

    RC = c.getResponseCode ();

    System.out.println ("response from the server" + rc);

    if (rc! = HttpsConnection.HTTP_OK) {

    throw new IOException ("HTTP response code:" + rc);

    }

    is = c.openInputStream ();

    Get the ContentType

    The string of type = c.getType ();

    The length and process data

    int len = (int) c.getLength ();

    if (len > 0) {

    int actual = 0;

    int BytesRead = 0;

    byte data = new byte[len]; while ((bytesread! = len) & (real! = - 1)) {

    real = is.read (data, bytesread, len - bytesread);

    bytesRead += real;

    }

    } else {}

    int ch;

    while ((ch = is.read (())! = - 1). {

    }

    }

    } catch (ClassCastException e) { throw new IllegalArgumentException ("not a HTTP URL");}

    }

    catch (IOException ioe) {}

    finally {

    Try

    {

    if (is! = null)

    is. Close();

    if (c! = null)

    c.Close ();

    }

    catch (IOException ioe) {}

    }

    }

    }

    When I run this program in the Simulator, I can do nothing. Please correct me if I'm wrong in coding.

    As I am new to this blackberry JDE environment, ideas and suggestions on how to write and run the sample applications in the blackberry are more welcomed.

    Concerning

    Hinduja

    Make sure that your MDS starts when the Simulator starts.  In the JDE will in Edition > Preferences > Simulator > General and click the checkbox "launch Mobile Data System connection with Simulator Service.

  • Bulding error with BlackBerry JDE project

    Hello

    I tried to create my application on BlackBerry JDE 5.0, and she's still fails with the following message is displayed:

    SimpleUI building
    C:\Program Research In Motion\BlackBerry JDE 5.0.0\bin\rapc.exe codename = SimpleUI SimpleUI.rapc warnkey = 0 x 52424200; 0 x 52525400; 0 x 52435200 import =... \lib\net_rim_api.jar "C:\Program search in Motion\BlackBerry JDE 5.0.0\bin\SimpleUI.java".
    Error while building project

    The same code can be built and run successfully on Eclipse with the BlackBerry plugin.

    Can anyone help?

    Check your path once again, I think that you are missing something in the path.

  • Parsing XML and get the attributes of a tag

    Hello

    When parsing XML for application of Cascades in C++, I am able to get the value of a tag as follows:

    00000

    But I also want to get the attributes of a tag:

    But I don't know how to get the 'CA' and 'California' attributes with my current code.  Can anyone help?  Here is the code I use to parse the XML code:

    void CMController::requestFinished(QNetworkReply* reply) {
    
        if (reply->error() == QNetworkReply::NoError) {
    
            QXmlStreamReader xml;
    
            QByteArray data = reply->readAll();
            xml.addData(data);
    
            QString zip;
            QString id;
            QString location;
    
            while (!xml.atEnd() && !xml.hasError()) {
    
                /* Read next element.*/
                QXmlStreamReader::TokenType token = xml.readNext();
    
                /* If token is just StartDocument, we'll go to next.*/
                if (token == QXmlStreamReader::StartDocument) {
                    continue;
                }
    
                /* If token is StartElement, we'll see if we can read it.*/
                if (token == QXmlStreamReader::StartElement) {
    
                    if (xml.name() == "zip") {
                        zip = xml.readElementText();
                    }
    
                    if (xml.name() == "id") {
                        ???
                    }
    
                    if (xml.name() == "location") {
                        ???
                    }
    
                }
    
            }
    
            emit succeeded(result);
    
        } else {
            emit failed();
        }
    
        reply->deleteLater();
    
    }
    

    Thank you!

    I found a working example:

    if(xml.name() == "state"){
        QXmlStreamAttributes attrib = xml.attributes();
        QStringRef ref = attrib.value("location");
        qDebug() << "location: " << ref;
    }
    
  • How do you see the System.out.println (without using Eclipse and BlackBerry JDE)

    Hi all

    I just want to know if there is no solution to see System.out.println.

    I use neither Eclipse nor BlackBerry JDE for my development.

    I have my jar, jad files. I convert my jar file using the CAP tool. The .cod files are generated.

    I start the trainer. Now I have 2 windows: Windows Simulor and the output (see picture).

    Then I load my .cod files. But I see not all System.out.println ("...") in the output windows.

    How can I see these System.out.println ("...")?

    Please help me.

    Thank you all.

    Thanks for your help.

    I try your solution EventLogger.

    But I have another problem:

    My request is not a native application (it is a midlet in J2ME, not a UIApplication). Do you think that it will work with EventLogger?

    How can I make a registry for EventLogger:

    static boolean register(long guid, String name) 
    Registers the name and the guid of the calling application.
    static boolean register(long guid, String name, int viewerType) 
  • How do I use a different version of the BlackBerry JDE?

    Hello

    I installed BlackBerry JDE version 4.5 to 6.0.

    How can I find out the current version used to Eclipse?

    I also try to change using the JDE follosing version this article, http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Confi...

    But there is no such ide.bat under the directory.

    Thank you.

    Under your project directory, there is a JRE System Library. Right-click on it and select Properties. After that, I think you know what to do.

    I hope this helps.

  • How to change the icon of the Application on Blackberry JDE 6

    Hi, do someone know how to change the icon of the application of the project, we have created in the JDE? I searched the forum, and suggestions should go to the project properties, go to the "resources" tab and add the icon file. I have also included the file icon (PNG 68x68pixel) to the project.
    But this does not seem to work for me.
    I also tried to build clean, remove files jad and others, always not when I tried the app Simulator or on real device. Any help will be appreciated.
    I use Blackberry JDE 6, test the application on the actual device (9800), Simulator (9700). And the app that I'm testing is just a pushscreen simple helloWorld app, not a lot of code here. Thank you.

    Here's how to put the icon in BlackBerry JDE.

    1. Add the image to your project.
    2. Right-click on the image and choose Properties.
    3. Check "use as icon for the Application.
    4. Rebuild the application.
  • Full duplex to BlackBerry JDE 4.7

    Hello

    I know that his duplex (play and record at the same time) is not supported in BlackBerry JDE 4.6.

    I saw the article - "not sure I have it is a bug or a feature. We use two players: one for record, another for reading ', but I couldn't find the solution.

    Does anyone know how to implement the application with the duplex sound?

    Alternatively, the BlackBerry JDE 4.7 does support duplex sound?

    Thank you.

    Best regards, Ricos.

    Yes. It is possible. Play and record on two separate applications. Oh, make basic applications.

  • BlackBerry JDE

    Hello

    I just installed the Blackberry JDE 6 and JDK (newest).

    After installation, it ran very well, so I closed the JDE and attempted to reopen it, it gives me the error message

    Cannot find RIMIDEWin32Util.dll. It is a prerequisite of the IDE.

    I HAV changed something that's directly after installation!

    Thank you

    In my setup, the RIMIDEWin32Util.dll file is here:

    C:\Program search in Motion\BlackBerry JDE 6.0.0\bin

    If you are running on Win 7, it could be a permissions problem.  Search the forum for Threads of installation of Win 7.  Most of them are in Eclipse, but you may get advice on things that can go wrong.

  • Install the simulators BlackBerry JDE 7.0, Windows 7

    I've developed for BlackBerry for awhile.  I lived two computers and many JDE.  Not once have I could download and install a simulator that works with the BlackBerry JDE.  Now, I don't really have a choice and I need to install the 9850 Simulator.

    The simulators that I download install and run standalone, but not BlackBerry JDE.  They are not displayed and my attempts to create a new profile of BlackBerry JDE Simulator so far have failed.

    I don't see anything when I did a search, surely someone else has had this experience.

    Thank you!

    Hi James,

    I have the JDE and several simulators device that runs correctly under Windows 7 64-bit set. Of course, I remove UAC before performing facilities. The JDE must be able to update the files when a new Simulator is detected and UAC seems to stand in this action.

    Turn off UAC (at your discretion, of course), then re - install would be an option to test. The other would be trying to install in a directory that your user account has or is governed by the UAC differently than the directory "Program Files" (computer desk or C:\).

    Kind regards

  • Device = BlackBerry software? Blackberry JDE version?

    Hey there everyone, I'm rather new in java programming on blackberry, and I feel like there is a mistake of very basic communication between me and my program.

    I am writing a small program to my blackberry a short work for me, but I don't know if it'll work on my older curve blackberry.

    I use Netbeans 6.8 and added the Blackberry JDE 6.0.0 as a custom Java ME platform.  So my question is:

    How can I make sure that the classes and methods of the JDE 6.0.0 will work on my long-since-updated Blackberry 8330 m, which has a software system 4.5.0.186 (Platform 3.2.0.59).  Is there something in the classes and methods that would make me look out?  I should rather check all my imports and the method calls against http://www.blackberry.com/developers/docs/4.5.0api/index.html ?

    Indeed, how can ensure me that I can use with BB, which are even older?

    the JDE version must be equal to or lower than the version of the BB OS. If for example on a device running 4.5.0, you can use 4.5.0, JDE 4.3.0 4.2.1 etc., descendant of the version of the device

  • What strategies companies follow when choosing a Smartphone in BlackBerry JDE?

    What strategies companies follow when choosing a Smartphone in BlackBerry JDE?

    I guess, since you are in a Java forum, that you plan to Java development.  There are a number of other options.  But looking at Java:

    You are concenred about what level of JDE?  Look here:

    http://com-BlackBerry-us-5p.WWWA.com/developers/choosingtargetos.jsp

    Or choice JDE or Eclipse?  If so choose Eclipse.

    If I have not answered your question, can you be more specific?

Maybe you are looking for