﻿var Xml = {}
Xml.getChildrenAsArray = function(node)
{
	var result = {};
	node.children().each(function()
	{
		var nodeName = $(this).get(0).nodeName;
		var nodeValue = "";
		if ($(this).children().size() > 0)
		{
			// Node has children, return children text in an array
			nodeValue = Array();
			$(this).children().each(function()
			{
				nodeValue.push($(this).text());
			});
		}
		else
		{
			// Node has no children, return node text
			nodeValue = $(this).text();
		}
		result[nodeName] = nodeValue;
	});
	return result;

}