2013-03-21 14 views
0

我需要在下面的結構中創建一個xml。在xml中混合了屬性和元素

<ipaddress> "10.10.10.10" </ipaddress> 
<PipeId pid = "4598702C-691E">testvalue</PipeId> --how to display this? 
<name> "testname" </name> 

但我對xml中的第二行非常困惑。它如何顯示?

我下面嘗試code..but不知道如何獲得第二線轉換成XML ..

new XElement("StartElement", 
new XAttribute("TestAtt", "some & value"), 
new XElement("ipaddress", "10.10.10.10"), 
new XElement("name", "testname"))); 
+0

你是什麼意思的「顯示」? – 2013-03-21 15:33:15

+0

我的意思是「如何寫入xml?」 – vinayan 2013-03-21 15:36:31

回答

2

如果你只是想建立一個元素,你想:

new XElement("PipeId",      // Name of the element 
    new XAttribute("pid", "4598702C-691E"), // Attribute of the element 
    "testvalue")        // Text content of the element 
+0

謝謝你。救了我! – vinayan 2013-03-21 15:37:02