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 8648313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:17:04+00:00 2026-06-12T13:17:04+00:00

hi am trying tp parse the xml in blackberry that stores in server. But

  • 0

hi am trying tp parse the xml in blackberry that stores in server. But it comes out in inputstream line with different exceptions.mostly with Datagram Protocol and TcpInput exceptions.i have attached my code here kindly guide me.

try {
    Document doc;
    StreamConnection conn = null;
    InputStream is = null;
    conn = (StreamConnection) Connector.open("http://xyz.com/GetImageDetails.xml;deviceside=true;");

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);
    docBuilderFactory.setCoalescing(true);

    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.isValidating();
    is = conn.openInputStream();
    doc = docBuilder.parse(is);
    doc.getDocumentElement().normalize();

    NodeList list = doc.getElementsByTagName("IMG_URL");
    for (int i = 0; i < list.getLength(); i++) {
        Node textNode = list.item(i).getFirstChild();
        System.out.println(textNode);
    }
} catch (Exception e) {
    System.out.println(e.toString());
}
  • 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-06-12T13:17:06+00:00Added an answer on June 12, 2026 at 1:17 pm
    The XML parsing class is
    /***/
    

    package com.application.xmlParser;

    import java.io.ByteArrayInputStream;
    import java.io.InputStream;
    import java.util.Hashtable;
    import java.util.Vector;

    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.helpers.XMLReaderFactory;

    import com.application.log.Log;

    public class CopyOfXMLParser extends DefaultHandler {

    private String RecordElement;
    private String xmlURL;
    private Hashtable newObj = new Hashtable();
    private Vector Records = new Vector();
    private CallBack callBack ;
    private String _localEndTag = "";
    
    public void ParseInputStream(String stream,String rootElement, String recordElement , CallBack callBack) 
    {
        RecordElement = recordElement;
        this.callBack = callBack;
    
        InputStream in = new ByteArrayInputStream(stream.getBytes());
        try 
        {
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(this);
            reader.parse(new InputSource(in));
        } 
        catch ( Exception e ) 
        {
            System.out.println("#### ##### Parse Exception : " + e + "#### #####" + xmlURL);
          /*  callbackAdapter.callback(Records);*/
        }
    }
    
    
    public void startElement(String Uri, String localName, String qName, Attributes attributes) throws SAXException 
    {
    }
    
    public void characters(char [ ] ch, int start, int length) throws SAXException 
    {
       String elementValue = new String(ch, start, length).trim();
    
        Log.d("End Tag", _localEndTag); 
        Log.d("Tag Value ", elementValue);  
    
        if(_localEndTag ==  null || _localEndTag.equalsIgnoreCase(""))
        {
    
        }
        else
        {
            newObj.put((String)_localEndTag, (String)elementValue);
        }
    }
    
    public void endElement(String Uri, String localName, String qName) throws SAXException 
    {
        _localEndTag = localName;
    
        if ( localName.equalsIgnoreCase(RecordElement) ) 
        {
            Records.addElement(newObj);
            callBack.callBack(Records);
            System.out.println("###### ###### FINISH ###### ######" +RecordElement);
        }
    }
    

    }

    /***/
    
    /***/
    How to Implement
    
    take the (Http)InputStream response into String  and call the below method ..your problem is solved 
    
    new CopyOfXMLParser().ParseInputStream(new String(baos.toByteArray()) ,"SOAP:Envelope", "SOAP:Envelope");
    

    I am getting all the elements value , with this code
    /*/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse out xml feeds from different sources, some news feeds
I'm trying to parse different XML that is returned depending on the command given
I'm trying to parse XML file (RSS Feed), but I have a problem that
I am trying to parse XML with jsoup, but I can't find any examples
Trying to parse some XML but apparently this is too much for a lazy
I am trying to parse an XML file with python using lxml, but get
I am trying to parse xml file and get no errors but when trying
I am trying to parse one XML file that contains some unicode characters.I tried
I'm trying to parse XML feed that I get via Google Contacts API with
I am trying to parse an xml file using XmlReader but although I am

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.