2017-10-12 14:09:52 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Dom.ParseXML
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} data - The XML source stored in a string.
|
|
|
|
*
|
|
|
|
* @return {any} [description]
|
|
|
|
*/
|
2016-12-07 04:43:02 +00:00
|
|
|
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;
|