I have a piece of content which has both html and rss, I would like to separate them and store in individual strings. So, I am trying to parse them based on their start and close tags and grab content between rss /rss .
Code works fine for html & /html. However I am seeing errors for rss & /rss.
Below is my code snippet.
// parse the responseStr to html
html = responseStr.substring(responseStr.indexOf("<html>"),
responseStr.lastIndexOf("</html>") + 7);
System.out.println("html string"+html );
Can someone please guide me what is wrong with the below code?
// parse the responseStr to rss
rss = responseStr.substring(responseStr.indexOf("<rss version="2.0">"),
responseStr.lastIndexOf("</rss>") + 6);
System.out.println("rss string = "+rss );
I get the below exception:
java.lang.StringIndexOutOfBoundsException
at java.lang.String.substring(String.java:1093)