Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:27:42+00:00 2026-05-30T22:27:42+00:00

i am working with xml in blackberry. i am currently working with a xml

  • 0

i am working with xml in blackberry.
i am currently working with a xml string, where, one of the values, is another xml string.
the problem is that , while the other values are being extracted neatly, the xml value is not.
only the “<” is being extracted from the node.

the same, seems to be working in normal java.
the only difference i can see is the way in which the request is seen:

in java project:

connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type",          "text/xml;charset=UTF-8");
        connection.setRequestProperty("Content-Length", "" +                             Integer.toString(resultText.getBytes().length));
        connection.setUseCaches(false);
        connection.setDoInput(true);
        connection.setDoOutput(true);

wheras, the blackberry uses:

http.setRequestMethod(HttpConnection.POST);
        http.setRequestProperty("User-Agent","Blackberry 8320/4.2.2        Profile/MIDP-2.0 Configuration/CLDC-1.1");

        http.setRequestProperty("x-rim-transcode-content", "none");
        http.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
        http.setRequestProperty("Content-Length","" + Integer.toString(resultText.getBytes().length));

and the following code is used to get the response from the web service::
in Java:

BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        String line;
        StringBuffer response = new StringBuffer();
        while ((line = rd.readLine()) != null) {
            response.append(line);
            response.append('\r');
        }
        rd.close();

in BB

InputStream inStream = http.openInputStream();
        // Get the length and process the data
        int len = (int) http.getLength();
        if (len > 0) 
        {
            int actual = 0;
            int bytesread = 0;
            byte[] data = new byte[len];
            while ((bytesread != len) && (actual != -1)) {
                actual = inStream.read(data, bytesread, len - bytesread);
                bytesread += actual;
            }
            String recd = new String(data, "UTF-8");
            responseData = recd;

other than this change, i cant see any other differences. the embedded xml gets extracted perfectly in a java project, but the bb project extracts only a “<” 🙁

any help would be much appreciated.

the xml file being parsed is here:( have not provided the full one. have removed all but one value in the embedded xml.

  response:::::<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas  .xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.o  rg/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sche  mas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:glwsdl"><SOAP-ENV:Body><return xsi:type="SOAP-ENC:Arr  ay" SOAP-ENC:arrayType="tns:CrosswordItem[1]"><item xsi:type="tns:CrosswordItem"><Date xsi:type="xsd  :string">2012-01-04</Date><Crossword xsi:type="xsd:stri  ng">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;crossword size=&quot;7&quot;&gt;
&lt;grid&gt;

&lt;cell position=&quot;5_6&quot; value=&quot;&amp;#xAB0;&amp;#xABE;&quot;/&gt;
&lt;cell position=&quot;6_6&quot; value=&quot;&amp;#xAA8;&quot;/&gt;
&lt;/grid&gt;
&lt;horizontalkeys&gt;
&lt;key number=&quot;19&quot; position=&quot;3_6&quot; length=&quot;4&quot;   answer=&quot;&amp;#xA9  C;&amp;#xABE;&amp;#xAAB;&amp;#xAB0;&amp;#xABE;&amp;#xAA8;&quot;  question=&quot;&amp;#xA95;&amp;#xAC7  ;&amp;#xAB8;&amp;#xAB0;&quot;/&gt;
&lt;/horizontalkeys&gt;
&lt;verticalkeys&gt;
&lt;key number=&quot;17&quot; position=&quot;6_5&quot; length=&quot;2&quot;   answer=&quot;&amp;#xAA  E;&amp;#xABE;&amp;#xAA8;&quot; question=&quot;&amp;#xA86;&amp;#xAAC;&amp;#xAB0;&amp;#xAC2;, &amp;#xA  AA;&amp;#xACD;&amp;#xAB0;&amp;#xAA4;&amp;#xABF;&amp;#xA  B7;&amp;#xACD;&amp;#xAA0;&amp;#xABE;&quot;/&gt;
&lt;/verticalkeys&gt;
&lt;/crossword&gt;
</Crossword><Gridsize xsi:type="xsd:string">7</Gridsize><Id      xsi:type="xsd:string">63</Id></item></re  turn></SOAP-ENV:Body></SOAP-ENV:Envelope>

edit:
i partially solved the problem:
using :

xmlEmbeddedData = xmlData.substring(xmlData.indexOf("&lt;?xml     version=&quot;1.0&quot;encoding=&quot;UTF-8&quot;?&gt;"),                           xmlData.indexOf("</Crossword>"));

i managed to extract what i needed into another string, with one problem, the xml string that i need to parse, now containes: ” & g t ; ” for >,” & l t ;” for < and “& q u o t ; & a m p ;”…without the spaces…

i need to decode the string and get back a xml string that i can parse.
can someone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:27:44+00:00Added an answer on May 30, 2026 at 10:27 pm

    ok-
    thought i might as well answer my own question:

    if (xmlData.indexOf("&lt;?xml version=&quot;1.0&quot; 
        encoding=&quot;UTF-&quot;?&gt;") != -1 && 
        xmlData.indexOf("</Crossword>") != -1) 
    {
        xmlEmbeddedData = xmlData.substring(
              xmlData.indexOf("&lt;?xml version=&quot;1.0&quot; 
                          encoding=&quot;UTF-8&quot;?&gt;"),xmlData.indexOf("</Crossword>"));
    }
    

    Above, i have extracted the embedded xml by simply extracting the string from the response data between the two indexes…
    below i replaced the < with the appropriate value.

    System.out.println("embedded--->" + xmlEmbeddedData);
        xmlEmbeddedData = replace(xmlEmbeddedData, "&lt;", "<", true);
        xmlEmbeddedData = replace(xmlEmbeddedData, "&gt;", ">", true);
        xmlEmbeddedData = replace(xmlEmbeddedData, "&amp;", "&", true);
        xmlEmbeddedData = replace(xmlEmbeddedData, "&quot;", "\"", true);
        xmlEmbeddedData = replace(xmlEmbeddedData, "\n", "", true);
    

    And this is the replace function:

    static public String replace(String val, String fnd, String rpl,
            boolean igncas) {
        int fl = (fnd == null ? 0 : fnd.length());
    
        if (fl > 0 && val.length() >= fl) {
            StringBuffer sb = null; // string buffer
            int xp = 0; // index of previous fnd
    
            for (int xa = 0, mi = (val.length() - fl); xa <= mi; xa++) {
                if (val.regionMatches(igncas, xa, fnd, 0, fl)) {
                    if (xa > xp) {
                        sb = append(sb, val.substring(xp, xa));
                    } // substring uses private construct which does not dup
                    // char[]
                    sb = append(sb, rpl);
                    xp = (xa + fl);
                    xa = (xp - 1); // -1 to account for loop xa++;
                }
            }
    
            if (sb != null) {
                if (xp < val.length()) {
                    sb.append(val.substring(xp, val.length()));
                } // substring uses private construct which does not dup char[]
                return sb.toString();
            }
        }
        return val;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a blackberry app that needs to connect to facebook
I'm currently working on XML (SVG) traversing and have the next problem: my function
I'm new to working with XML, and I've encountered a weird problem while trying
I'm working with XML that was designed by somebody who got paid by the
I'm working with XML and Flash. I tried to pass XML values to my
I'm working with an XML document that contains a structure that looks similar to
I am working on blackberry java development. I am having a xml file: <?xml
Currently I am working with XML and I want to know what would be
I have my parsing xml working but I want to pick up One value
well i am working with xml but it is not important now, the problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.