• Rajasekhar Reddy 44
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
HI,
I am calling one web service and getting response in XML and while iterating through that XML i got below exception

System.XmlException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog.

Code:
 HttpRequest req = new HttpRequest();
        String url='abaccc';

        req.setEndpoint(url);
        req.setMethod('GET');
        // Send the request, and return a response
        HttpResponse res = h.send(req);
        XmlStreamReader reader = res.getXmlStreamReader();
        // Read through the XML
        while(reader.hasNext()) {
            System.debug('Event Type:' + reader.getEventType());
            if (reader.getEventType() == XmlTag.START_ELEMENT) {
            System.debug('Local name :'+reader.getLocalName());
            }
            reader.next();// Getting exception at this line.
        }

 Can anybody help me?

Thanks
Yash