// takes a DOM element and returns a serialized XML string of the element and all siblings
function serializeToXML(el) {
	var xmlStr = '',
	    i;
	if (el.nodeType == 1) { // element node
		xmlStr += '<';
		xmlStr += el.nodeName.toLowerCase();
		// attributes
		if (el.attributes.length > 0) {
			for (i = 0; i < el.attributes.length; i++) {
				// filter out some IE madness (they give you all attributes, not just the user ones)
				if (el.attributes[i].nodeValue != null && el.attributes[i].nodeValue != '' && el.attributes[i].nodeName != 'contentEditable') {
					xmlStr +=  ' '+el.attributes[i].nodeName+'=\''+el.attributes[i].nodeValue+'\'';
				}
			}
		}
		if (el.childNodes.length > 0) {
			xmlStr += '>';
			for (i = 0; i < el.childNodes.length; i++){
				xmlStr += serializeToXML(el.childNodes[i]);
			}
			xmlStr += '</'+el.nodeName.toLowerCase()+'>';
		} else {
			xmlStr += '/>';
		}
	} else if (el.nodeType === 3) { // text node
		if (!el.isElementContentWhitespace) { // non empty
			var t = (el.nodeValue).replace(/^\s+|\s+$/g, ''); // trim (start and end)
			t = t.replace(/\s{2,}/g, ' '); // remove internal extra whitespace
		//	t = t.replace(/\s/g, ' '); // convert all whitespace characters to normal spaces (not needed)
			xmlStr += t;
		}
	} else { // other node
		alert('other node type');
	}
	return xmlStr;
}
