Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用c语言创建特定格式的XMl文件_C#_Xml - Fatal编程技术网

C# 用c语言创建特定格式的XMl文件

C# 用c语言创建特定格式的XMl文件,c#,xml,C#,Xml,我想用c创建以下格式的xml文件 你好 世界 试试这个 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Linq; namespace ConsoleApplication85 { class Program { static void Main(string[] a

我想用c创建以下格式的xml文件

你好 世界 试试这个

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;


namespace ConsoleApplication85
{
    class Program
    {
        static void Main(string[] args)
        {
            //<custom>
            //    <text1>
            //    <value name="sample1">hello</value>
            //    </text1>
            //    <text1><value name="sample2">world</value> 
            //    </text1>  
            //    </custom>

            XElement custom = new XElement("custom", new object[] {
                new XElement("Text1", new object[] {
                   new XElement("value", new object[] {
                      new XAttribute("name", "sample1"),
                      "hello"
                   })
                }),
                new XElement("Text1", new object[] {
                   new XElement("value", new object[] {
                      new XAttribute("name", "sample2"),
                      "world"
                   })
                })
            });

        }
    }
}

“问题是什么?”卡拉,我想这是一个要求。现在就给他写@NitinK到目前为止你尝试了什么?你在哪里被卡住了?请阅读:可能的副本