/**
 * fsairlines.xml.utils.js
 *
 * XML reader
 *
 * @author Claudio Gusmini
 * @version 0.1
 */


/**
 * XML-Parser utility function. Gets the content of a node in an XML file.
 * @param node  Name of the node.
 */
function getNodeContent(node) {
	if (node == null) return null;
	
    var content = node.text; //Internet Explorer
    if (typeof(content) == 'undefined' || content == null) {
        content = node.textContent; //Firefox
    }
    if (typeof(content) == 'undefined' || content == null) {
        content = node.nodeValue; //Opera
    }
    return content;
}


function getString(xml, tag) {
	node = xml.getElementsByTagName(tag)[0];
	
 	if (typeof(node) == 'undefined') return null;
				
	value = getNodeContent(node);
	return value;
}

function getInt(xml, tag) {
	node = xml.getElementsByTagName(tag)[0];
	
 	if (typeof(node) == 'undefined' || node == null) return null;
				
	value = getNodeContent(node);
	return parseInt(value);
}

function getBoolean(xml, tag) {
	node = xml.getElementsByTagName(tag)[0];
	
 	if (typeof(node) == 'undefined') return null;
				
	value = getNodeContent(node);
	if (value == "false") return false;
	else return true;
}
