Write a method extractTitle that takes a string as input parameter representing IMDB movie information (written in XML style), and extracts all of the text between the tags and . Your method can assume that there will be at most one movie title inside the input string.
Example: extractTitle("Split (2017)6375308") returns "Split (2017)"
public class ExtractTitle {
public static void main(String[] args) {
System.out.println(extractTitle("<item><title>Split (2017)</title><meta><imdb>6375308</imdb></meta>"));
}
public static String extractTitle(String data) {
int startIndex = data.indexOf("<title>");
if (startIndex == -1) return "";
int endIndex = data.indexOf("</title>", startIndex);
if (endIndex == -1) return "";
return data.substring(startIndex + 7, endIndex).trim();
}
}
Write a method extractTitle that takes a string as input parameter representing IMDB movie information (written...