public void SaveLoadXMLWithEscapeChars_AltXML_AltXML() { AltXmlDocument altDocument = new AltXmlDocument("root", ""); AltXmlNode node = new AltXmlNode("node", "'\"&<>\t\n\r"); altDocument.RootNode.SubNodes.AddLast(node); byte[] data = altDocument.GetXmlData(); AltXmlDocument loadedDocument = new AltXmlDocument(data.GetString()); Assert.AreEqual("'\"&<>\t\n\r", loadedDocument.RootNode.SubNodes.First.Value.Value); }
/// <summary> /// Serializes an information to the array of the bytes. /// </summary> /// <param name="className"> Name of the class. </param> /// <param name="values"> Values (primitive). </param> /// <returns> Array of the bytes. </returns> protected virtual byte[] SerializeInfo(string className, IDictionary <string, string> values) { AltXmlDocument document = new AltXmlDocument(RootNodeString, ""); AltXmlNode classNode = new AltXmlNode(ClassNodeString, ""); document.RootNode.SubNodes.AddLast(classNode); AltXmlAttribute attribute = new AltXmlAttribute(NameAttributeString, className); classNode.Attributes.AddLast(attribute); foreach (var pair in values) { classNode.SubNodes.AddLast(new AltXmlNode( pair.Key, pair.Value ?? NullIdentifier)); } return(document.GetXmlData()); }