PHP Classes
elePHPant
Icontem

File: server.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Bas van Gaalen  >  dom xml class  >  server.php  >  Download  
File: server.php
Role: Auxiliary script
Content type: text/plain
Description: Server simulation - used in functest.php
Class: dom xml class
An implementation of the DOM XML standard
Author: By
Last change:
Date: 11 years ago
Size: 859 bytes
 

Contents

Class file image Download
<?php

   
// Include the xml library
   
include('lib.xml.inc.php');

   
// Get input data, quit on empty input
   
$input = $GLOBALS['HTTP_RAW_POST_DATA'];
    if (empty(
$input)) exit;

   
// Create XML from input
   
$qXML = new XML();
   
$qXML->parseXML($input);

   
// Get name from input
   
$name = $qXML->firstChild->firstChild->firstChild->nodeValue;
   
$msg = 'Hello there '.$name;

   
// Echo back an XML message
   
$rXML = new XML();
   
$rXML->xmlDecl = '<?xml version="1.0" encoding="ISO-8859-1" ?>';

   
// Create query element
   
$response = $rXML->createElement('response');

   
// Create message element
   
$message = $rXML->createElement('message');
   
$text = $rXML->createTextNode($msg);
   
$message->appendChild($text);
   
$response->appendChild($message);

   
// Append response to object
   
$rXML->appendChild($response);

   
header("Content-Type: text/xml");
    echo
$rXML->toString();

?>