I am trying to read an hosted xml file from server but it returns as garbage value. Below is my code:-
var url = 'http://www.tipgin.net/example-data/livescore-feed-example.xml';
var req = http.get(url, function(response) {
// save the data
var xml = '';
res.set('Content-Type', 'text/html');
response.on('data', function(chunk) {
xml += chunk;
res.write(chunk);
});
response.on('end', function() {
// parse xml
res.write(xml);
res.end();
});
// or you can pipe the data to a parser
//res.pipe(dest);
}).on('error', function(err) {
// debug error
});
In the response it prints out as below:-
��]�r۸�}��`�aj�!n\x�t���Ĺ'>q�s�tMu�$1�HP���������y�o�� �"!/�s^Z����7�?���e��pQ�E���#���b����G�z�$>��O?f� /'��^���5�>="�1"����䄢y����Ge1�pq�����+�M�*_���G,�s��#/gK���T=���7�\��L��ӣs����K�L �CWW��oG?��d���cٚ��~�B ���~�����(�B9l�\�|��2��嫘o���1���(�l�N���G��(�|��H�AUl� .....
I have tried other XML service and that works fine. This issue persist only with this url when I try to access the file. Is there anything additional I have to add into the code here?