mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 12:33:38 +00:00
34 lines
594 B
JavaScript
34 lines
594 B
JavaScript
|
var ParseXML = function (data)
|
||
|
{
|
||
|
var xml = '';
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (window['DOMParser'])
|
||
|
{
|
||
|
var domparser = new DOMParser();
|
||
|
xml = domparser.parseFromString(data, 'text/xml');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
xml = new ActiveXObject('Microsoft.XMLDOM');
|
||
|
xml.loadXML(data);
|
||
|
}
|
||
|
}
|
||
|
catch (e)
|
||
|
{
|
||
|
xml = null;
|
||
|
}
|
||
|
|
||
|
if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return xml;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = ParseXML;
|