码迷,mamicode.com
首页 > 其他好文 > 详细

XmlSerializer 实现序列化CDATA

时间:2018-05-03 22:11:25      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:pre   des   rem   val   set   data   this   cdata   turn   

     [XmlIgnore]
        public string GuestRemarks { get; set; }

        [XmlElement("GuestRemarks")]
        public XmlNode[] Nodes
        {
            get
            {
                var dom = new XmlDocument();
                return new XmlNode[] {dom.CreateCDataSection(this.GuestRemarks)};
            }
            set
            {
                if (value == null)
                {
                    this.GuestRemarks = null;
                    return;
                }

                if (value.Length != 1)
                    throw new InvalidOperationException("Invalid array.");
                var content = value[0];
                if (null == content)
                    throw new InvalidOperationException("Node is null.");
                this.GuestRemarks = content.Value;
            }
        }

 

XmlSerializer 实现序列化CDATA

标签:pre   des   rem   val   set   data   this   cdata   turn   

原文地址:https://www.cnblogs.com/ShaYeBlog/p/8987319.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!