2016-04-19 14 views
-4

に作成します。xmlファイルをC#で下のフォーマットで作成したいと思います。特定のフォーマットのXMlファイルをC#

<custom> 
 
<text1> 
 
<value name="sample1">hello</value> 
 
</text1> 
 
<text1><value name="sample2">world</value> 
 
</text1> 
 
</custom>

+3

をお試しください – Carra

+2

@Carra、私はそれが要求だと思う。今すぐ彼のためにそれを書いてください! –

+1

@NitinKこれまでに何を試したことがありますか?どうすればよい質問ができますか?](http://stackoverflow.com/help/how-to-ask) – har07

答えて

0

質問は何ですか?この

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" 
        }) 
       }) 
      }); 

     } 
    } 
} 
関連する問題