Solution:
slip8-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", "slip8-p1-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>
slip8-p1-q2.php
<?php
$d=new DOMDocument();
$d->load("slip8-p1-q2.xml");
$run=$d->getElementsByTagName('runs');
$wic=$d->getElementsByTagName('wickets');
$name=$d->getElementsByTagName('player');
foreach($name as $n)
{
if($a='')
echo "<br>".$n->textContent;
else "not";
}
?>
slip8-p1-q2.xml
<?xml version='1.0' encoding='UTF-8'?>
<cricketinfo>
<cricket>
<player>abc</player>
<runs>1000</runs>
<wickets>50</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>def</player>
<runs>100</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>pqr</player>
<runs>1020</runs>
<wickets>60</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>xyz</player>
<runs>9000</runs>
<wickets>90</wickets>
<noofnotout>40</noofnotout>
</cricket>
<cricket>
<player>lmn</player>
<runs>170</runs>
<wickets>80</wickets>
<noofnotout>8</noofnotout>
</cricket>
</cricketinfo>
0 Comments