Suppose I have a string which contains an HTML file. How do I get the script part only as my sub string?
The example string is :
str="<html>...<script>...</script>...</html>"
I only need the script part.
<script type = "text/javascript">
function Showques()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//getting response from servlet
xmlhttp.onreadystatechange=function();
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var localString=xmlhttp.responseText;
var locationstart =localString.indexOf('<script>');
var locationend = localString.indexOf('</script>');
//eval(xmlhttp.responseText);
document.getElementById("ques").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","XmlApp",true);
xmlhttp.send();
}
</script>
When I give </script> within indexOf method it's considering as the end of my script which i declared in the beginning and rest of things I am getting error.