Forum Moderators: travelin cat
Here's the code snippet:
var commandLine = '/usr/bin/curl http://www.mysite.com/some_xml.php'
var output = widget.system(commandLine, null).outputString;
document.getElementById('data').innerHTML = output The data div contains "undefined" as the string value if there's an accented character, etc.
It looks like
curl doesn't understand the non-ASCII character and hands the Widget something that makes it choke. Any suggestions to solve or eschew this problem?
On a side note, if you are gathering XML formatted data from your server, you may want to use XMLHttpRequest [developer.apple.com] to gather your data.
Regarding htmlentities(), when I originally tried this the xml parser complained about the entities that were created (didn't like à if I recall). So I used the xmlentities() function contributed on this page:
[us2.php.net ]
You mentioned:
check for any header output generated by the curl request
I did this by running the curl command in Terminal, but didn't see anything. Am I missing something there?
Although it's working, I will check out XMLHttpRequest since that looks like it may be the way of the future here.
curl http://www.example.com/some_script.php -D header.txt
the requested page will be displayed and the headers will be written to the file "header.txt". I would like to know what the solution to your problem was. If you do decide to use XMLHttpRequest, be sure to put
header("Content-type: text/xml");
at the beginning of your output script or the xml parser will choke and you might end up pulling out your hair for a few hours trying to figure our what is wrong :) .