Solution:
slip1-p1-q2.html
<html>
<script type="text/javascript">
function display()
{
name=f1.txt.value;
var xmlhttp;
if(window.XMLHttpRequest)
{
xmlhttp= new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "slip1-p2-q2.php?txt="+ name,false);
xmlhttp.send();
document.getElementById('result').innerHTML=
xmlhttp.responseText;
}
</script>
<body>
<form name="f1">
Enter Employee name:
<input type="text" name="txt" onKeyUp="display()"/><br>
</form>
<div id='result'></div>
</body>
</html>
slip1-p1-q2.xml
<?xml version="1.0"?>
<Movie_Store>
<Movie>
<Category>Biography</Category>
<MovieName>Dangal</MovieName>
<ReleaseYear>2016</ReleaseYear>
</Movie>
<Movie>
<Category>Action</Category>
<MovieName>Tanhaji</MovieName>
<ReleaseYear>2020</ReleaseYear>
</Movie>
<Movie>
<Category>Family</Category>
<MovieName>The Sky is Pink</MovieName>
<ReleaseYear>2019</ReleaseYear>
</Movie>
</Movie_Store>
slip1-p2-q2.php
<?php
$msearch=$_GET['txt'];
$xml=simplexml_load_file("slip1-p2-q2.xml");
echo $xml->getName()."<br>";
$hint="";
$len=strlen($msearch!=="");
if($msearch !=="")
{
foreach($xml->children() as $student)
{
//if(strstr($movie->MovieName,substr($msearch,0,$len)))
if(strcmp($msearch,$student->sname)==0)
{
$hint=" Student Name: $student->sname <br>
Cname: $student->cname<br>
Percentage:$student->percentage<br>";
}
}
}
echo $hint==="" ? "no suggestion":$hint;
?>
slip1-p2-q2.xml
<Course>
<SYBBACA>
<sname>Harsh</sname >
<cname>SYBBACA</cname >
<percentage>82</percentage>
<sname>Yash</sname >
<cname>SYBBA</cname >
<percentage>90</percentage>
<sname>Aman</sname >
<cname>SYBBAIB</cname >
<percentage>67</percentage>
<sname>Ajay</sname >
<cname>FYBBAIB</cname >
<percentage>77</percentage>
<sname>Raj</sname >
<cname>FYBBA</cname >
<percentage>87</percentage>
</SYBBACA>
</Course>
0 Comments