Jump to content

problem with xml usage


swethak

Recommended Posts

hi,

 

i have below mentioned code is there.In that use XML.I didn't understand this code.What purpose this code can write?what is the functionality of below code.Any body please suggest the answer....

 

<?
require_once 'lib/inc/functions.lib.php';
includeClasses('vehicle');

$oVeh = new VEHICLE;

$RetVal  = 1;
$MsgXML  = '';
$RVXML   = '';
$GETXML  = '';
$POSTXML = '';

if(count($_REQUEST) > 0)
{
$Type = isset($_REQUEST['Type']) ? $_REQUEST['Type'] : '';
$Page = isset($_REQUEST['Page']) ? $_REQUEST['Page'] : ''; 

$Vehicles = $oVeh->getVehicles($Page - 1, '`vehicle_dt_added` DESC', "`vehicle_type` = '{$Type}'");
if($Vehicles !== FALSE && count($Vehicles) > 0)
{
  foreach ($Vehicles as $aVehicle)
  {
   $RVXML .= "<Vehicle>\n";
      
   foreach ($aVehicle as $Key=>$Value)
   {
    $Key = str_replace(' ', '-', $Key);
    $Value = htmlentities($Value);
    $RVXML .= "<{$Key}>{$Value}</{$Key}>\n";
   }

   $RVXML .= "</Vehicle>\n";
  }
  
  $RVXML = "<Vehicles Total=\"".count($Vehicles)."\">\n{$RVXML}</Vehicles>\n"; 
}
else
{
  $RetVal = 0;
  $MsgXML = "<Message>No RV Vehicles found!</Message>\n";
}
}
else
{
$RetVal = -1;

if(count($_SESSION['ERRORS']) > 0)
  $MsgXML = "<Message>".implode("\n", $_SESSION['ERRORS'])."<Message>\n";
else 
  $MsgXML = "<Message>Some Error Occured!<Message>\n";
}




if(count($_GET) > 0)
{
foreach ($_GET as $Key=>$Value)
  $GETXML .= "<{$Key}>{$Value}</{$Key}>\n";
  
$GETXML = "<GET>\n{$GETXML}</GET>\n";  
}

if(count($_POST) > 0)
{
foreach ($_POST as $Key=>$Value)
  $POSTXML .= "<{$Key}>{$Value}</{$Key}>\n";
  
$POSTXML = "<POST>\n{$POSTXML}</POST>\n";  
}

header('Content-type: text/xml');
echo "<Result Code=\"{$RetVal}\">\n".$MsgXML.$GETXML.$POSTXML.$RVXML."</Result>"; 

?>

Link to comment
https://forums.phpfreaks.com/topic/113706-problem-with-xml-usage/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.