Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Problem in XML parsing

Hi

I am doing XML parsing but getting this error

"Document has no root element!".

 

I have checked the response in web browser, its working fine.


Here is the response...

<result>

<value>1</value>

<message>Got the response</message>

</result>

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in XML parsing

How are passing the document to the parser? 

 

I am guessing that since you say that the browser displays it fine, it is coming from a http request.  Instead of getting t from there, hard code the document in your application and see if that parsers correctly.  Then you will be able to determine if the error is in the http processing or the parsing. 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

I have used the same parsing technique to some other url its showing the correct result.

 

i am getting the correct response some days back but now its showing error.

 

Please use plain text.
Developer
peter_strange
Posts: 19,604
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in XML parsing

So the problem is in the URL then - debug that part of the processing.  What data is the Server giving you?

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

The url is correct.

The response i am getting from the server is :

<result>

<value>1</value>

<message1>Got the data!!</message1>

</result>

 


When i press the save button in my application i got this response.

But i am getting the exception here:- as runtime Exception

 

 

 public Element getRootElement () {
        RuntimeException e= new RuntimeException();
        if (rootIndex == -1)
              throw new RuntimeException ("Document has no root element!"+e.getMessage());

        return (Element) getChild (rootIndex);
        }

 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

Still getting this error?

Please use plain text.