PHP with XML

windows

Guest
This is the XML structure:

- <Exams>
- <exam>
<examno>AC1000</examno>
<examtype>ABC</examtype>
- <dates>
<date>24-09-2005</date>
<date>15-10-2005</date>
<date>22-04-2006</date>
<date>17-06-2006</date>
<date>22-07-2006</date>
</dates>

</exam>


This is the coding I am using to retrieve the data from the XML file:

<?
$name=$_GET['examtype'];
?>
<strong></strong>
<?php
// Create a DOMDocument instance
$xml = new DOMDocument;

// Ignore whitespace between nodes (default: true)
$xml->preserveWhiteSpace = false;

// Load the XML data source
$xml->Load('exam.xml');

// Create a DOMXpath instance based on the
// DOMDocument object
$xpath = new DOMXPath($xml);
// Construct the XPath expression, including a predicate
// in this instance.

$qry = '/exams/exam/examtype[. = "'.$name.'"]';
$entries = $xpath->query($qry);







foreach ($entries as $entry)
{

?>


<form name="form1" method="post" action="examprocess.php">

<table width="907" border="1" cellpadding="0" cellspacing="0" bordercolor="#000066">
<!--DWLayoutTable-->
<tr>
<td width="133" height="24" valign="top"><div align="center"><strong>Exam Type </strong></div></td>
<td width="151" valign="top"><div align="center"><strong>Location</strong></div></td>
<td width="160" valign="top"><div align="center"><strong>Date</strong></div></td>
<td width="147" valign="top"><div align="center"><strong>Capacity</strong></div></td>
<td width="109" valign="top"><div align="center"><strong>Operator</strong></div></td>
<td width="193" valign="top"><div align="center"><strong>&& </strong></div></td>
</tr>

My date output is
24-09-200515-10-200522-04-200617-06-200622-07-2006

I need output like
<select >
<option>24-09-2005</option>
<option>15-10-2005</option>
<option>22-04-2006</option>
<option>17-06-2006</option>
<option>22-07-2006</option>
</select>
I need it using XPath or DOM(XML) with PHP . can u help me to solve it?You're missing the XML header so your browser is rendering it as HTML.
 
Back
Top