zoukankan      html  css  js  c++  java
  • LINQ to XML:如何读写XCData

    using System;
    
    using System.Xml.Linq;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                //写入CDATA元素块
                var doc = 
                    new XElement("Test",
                        new XElement("User",
                            new XAttribute("name", "chenxizhang"),
                            new XCData("这是XCData的内容,可以包含特殊字符,例如< 或者 >")));
                Console.WriteLine("写入CData元素");
                Console.WriteLine(doc.ToString());
    
                Console.WriteLine("读取CData元素");
                Console.WriteLine(doc.Element("User").Value);
    
            }
        }
    }
    

    image

  • 相关阅读:
    The AndroidManifest.xml File
    handlebars简单用法
    高性能跨语言模板引擎Crox
    C++17 新特性
    C++ 14新特性
    [lua]笔记
    [lua]笔记
    delphi关键字
    delphi 基础
    TCP/UDP
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/1649741.html
Copyright © 2011-2022 走看看