protected static XmlNode SerializeToXmlElement(string serializedValue) { XmlDocument doc = new XmlDocument(); XmlElement valueXml = doc.CreateElement("value"); if (serializedValue == null) { serializedValue = string.Empty; } // We need to escape string serialized values serializedValue = XmlEscaper.Escape(serializedValue); valueXml.InnerXml = serializedValue; // Hack to remove the XmlDeclaration that the XmlSerializer adds. XmlNode unwanted = null; foreach (XmlNode child in valueXml.ChildNodes) { if (child.NodeType == XmlNodeType.XmlDeclaration) { unwanted = child; break; } } if (unwanted != null) { valueXml.RemoveChild(unwanted); } return(valueXml); }
protected static string GetParamStr(string key, string value) { if (value == null) { return(key + '='); } return(key + '=' + StringQuoter + XmlEscaper.Escape(value) + StringQuoter); }