Windows.Data.Xml.Dom.XmlDocument.CreateCDataSection C# (CSharp) Method

CreateCDataSection() public method

public CreateCDataSection ( [ data ) : XmlCDataSection
data [
return XmlCDataSection
		public extern XmlCDataSection CreateCDataSection([In] string data);
		public extern XmlAttribute CreateAttributeNS([Variant] [In] object namespaceUri, [In] string qualifiedName);

Usage Example

        async private void save_click(object sender, RoutedEventArgs e)
        {
            try
            {
                Windows.Storage.StorageFile file = null;
                Windows.Storage.StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml("<profile/>");
                XmlElement userNode = xmlDoc.CreateElement("username");
                XmlElement emailNode = xmlDoc.CreateElement("email");
                XmlElement phoneNode = xmlDoc.CreateElement("phone");

                XmlCDataSection userName = xmlDoc.CreateCDataSection(input_username.Text);
                XmlCDataSection email = xmlDoc.CreateCDataSection(input_email.Text);
                XmlCDataSection phone = xmlDoc.CreateCDataSection(input_phone.Text);

                userNode.AppendChild(userName);
                emailNode.AppendChild(email);
                phoneNode.AppendChild(phone);

                xmlDoc.DocumentElement.AppendChild(userNode);
                xmlDoc.DocumentElement.AppendChild(emailNode);
                xmlDoc.DocumentElement.AppendChild(phoneNode);
                bool createFile = false;
                try
                {
                    file = await local.GetFileAsync("profile.xml");
                }
                catch
                {
                    createFile = true;
                }
                if(createFile)
                {
                    file = await local.CreateFileAsync("profile.xml");
                }
                await xmlDoc.SaveToFileAsync(file);                               
            }
            catch { }
            this.navigationHelper.GoBack();
        }