I think the rigth way to do this is with SOAP.
I know the SOAP is the XML over HTTP, and do exactly what you want. But how... I don't know. I'm just learning.
see you
(From http://www.w3schools.com I've recently getted this example:
<html>
<head>
<script type="text/javascript">
function search()
{
var parser=new ActiveXObject("microsoft.xmldom")
parser.async="false"
parser.load("tryxml_send.php?query=" + query.value)
nodes = parser.documentElement.childNodes
answer_text.innerHTML=nodes.item(0).text
answer_xml.value=parser.xml
}
</script>
</head>
<body>
<h2>Sending a query to the server
and receiving the answer as XML:
</h2>
<p><b>Query: </b>
<input type="text" name="query" value="How Old">
<input type="button" value="Send to Server" onClick="search()">
</p>
<p><b>Answer from server is:</b>
<span id="answer_text"></span>
</p>
<p><b>XML from server is:</b><br>
<textarea id="answer_xml" cols="80" lines="10" rows="1">
</p></body>
</html>
and with php I do this:
<?
/* for debug purpose, I'm writing the query... */
$fil=fopen("temp.txt","wb");
fwrite($fil,$query);
fclose($fil);
header("Content-Type: text/xml");
echo "<answer><text>12 Years</text></answer>";
?>
)