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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.