Location: PHPKode > scripts > dom xml class > dom-xml-class/server.php
<?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();

?>
Return current item: dom xml class