While parsing an HTML response getting rid of CDATA



On hitting an API , I am getting a text/html response. I am trying to parse the response in Scala using

xmlObj = XML.loadString(response)

However as certain sections are not enclosed in the ![CDATA tag the parser is giving :

SAX Parser exception as it is not able to parse characters like &#0 . Can someone tell me how to go about it as all I want to do is extract the content enclosed with the "body" tag.

Right now I am trying something like this:

xmlResult = (xmlObj // "body").text


Thanks in advance :)


No comments:

Post a Comment