private string getBlock(XMLElement node) { string result = "<" + node.Name; if (node.hasAttributes()) { foreach (var attr in node.getAttributesList()) { result += " " + attr.Name + "=" + "\"" + attr.Value + "\""; } } if (!(node.hasText() || node.hasChildren())) { result += "/>"; } else { result += ">"; if (node.hasText()) { result += node.getText(); } if (node.hasChildren()) { foreach (var child in node.getChildrenList()) { result += getBlock(child); } } result += "</" + node.Name + ">"; } return(result); }