mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 04:23:30 +00:00
33 lines
594 B
JavaScript
33 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;
|