There is an at uploading xml file and in parsing.However, I don't have any experience with handling uploaded files in PHP yet. So thanx in advance.Should I use the $_FILES and do I always have to use a temporary file or can it be done completely in memory? code:
switch($cmdButton){
case "parse an xml document";
$default_dir = "";
$xml_string = file_get_contents($default_dir . "/" . "file");
$xp=xml_parser_create();
xml_parser_into_struct($xp, $xml_string, $values, $keys);
xml_parser_free($xp);
break;
}
}
?>
<table width="100%" border="1">
<tr><td><font face="Arial, Helvatica, sans-serif" size="-1">
<b>parse an xml document</b></font></td></tr><tr><td>
<font face="Arial, Helvatica, sans-serif" size="-1">
<b>choose xml document</b></font></td></tr>
<td>
<?php
echo "<select name=\"file\">\n";
foreach (new DirectoryIterator('.') as $file) {
// if the file is not this file, and does not start with a '.' or '..',
// then store it for later display
if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
echo "<option>";
// if the element is a directory add to the file name "(Dir)"
echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename();
echo "</option>\n";
}
}
echo "</select>\n";
?>
</select></td><tr><tr>
<td><font face="Arial, Helvatica, sans-serif" size="-1">
<b>xml file contents</b></font><hr>
<?php
if($cmdButton =="parse an xml document"){
echo "keys array<BR><BR><PRE>";
print_r($keys);
echo "</PRE><BR><BR>values array<BR><BR><PRE>";
print_r($values);
echo"</PRE>";
}
?>
No comments:
Post a Comment