Hi there,
Building an XMLRPC server application.
The problem I am having is that I need to send html as a response, however the response is being recieved escaped using htmlspecialchars.
ie, this:
<html>
<body>
This is some text.
<script>
var thing="blah";
</script&rt;
</body>
</html>
becomes this in the response:
EDIT: Spaces put in artificially after ampersands to prevent the browser rendering them as entities.
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>htmloutput</name>
<value>
<string>& lt;html& gt;& lt;body& gt;This is some text.& lt;script& gt; var thing=& quot;blah& quot;;& lt;/script& gt;& lt;/body& gt;& lt;/html& gt;</string>
</value>
</member>
</struct></value>
</param>
</params>
</methodResponse>
and once the client outputs the result, the script tag has also been stripped:
& lt;html& gt;& lt;body& gt;This is some text. var thing="blah";& lt;/body& gt;& lt;/html& gt;
My testing here is using the example lifted straight form the manual:
http://codeigniter.com/user_guide/libraries/xmlrpc.html
Except the server response is formulated as follows:
$string = '<html><body>This is some text. var thing="blah";</body></html>';
$response = array (
array(
'htmloutput' => array($string, 'string')
),
'struct'
);
Looking through the XML-RPC code I can see that htmlspecialchars is used, while not ideal I suppose I can get round that with htmlspecialchars_decode. Or alternativley alter the library so as to allow it to send html using cdata
I haven’t yet found how the tags are being removed, which is somewhere in the client library.
So my question is ...
How the hell do I send html with javascript?
Or shoudl I RTFM a bit more
?
http://www.xmlrpc.com/spec
