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

Native Development

Reply
Contributor
Posts: 21
Registered: ‎05-28-2013
My Device: Z10

Keep getting premature end of document when using XmlDataAccess.loadFromBuffer

Hi,

 

I am trying to consume a XML payload from server, although I checked online to make sure the XML payload is well formed, which it should be, it's coming from a public available API, but when I use XmlDataAccess loadFromBuffer to process it, it keeps saying Premature End of Document

 

void ApplicationUI::onRequestFinished ( QNetworkReply* reply )
{
    QNetworkReply::NetworkError netError = reply->error();
    qDebug() << "Web service call with response : " << reply->readAll();
    this->loadingIndicator->stop();

    if(netError == QNetworkReply::NoError)
    {
        // Emit updateListView signal to set the
        // new data model on the list.

    	QByteArray response = reply->readAll();
    	bb::data&colon;:XmlDataAccess xda;
    	QVariant list = xda.loadFromBuffer(response);

    	qDebug() << "XML Payload : " << list.toString();
    }
.....

 Output:

 

Web service call with response :  "<?xml version="1.0" encoding="UTF-8"?>

<trac........ is en ...

XML Payload :  "" 

 

Thanks

Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Keep getting premature end of document when using XmlDataAccess.loadFromBuffer

xda.loadFromBuffer(response);

response is empty because you call reply->readAll() in the code above

qDebug() << "Web service call with response : " << reply->readAll();
After first calll reply->readAll() is deleted.


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog