vinayan
vinayan

Reputation: 1637

mixed up attributes and elements in xml

I need to create an xml the below structure.

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

But I am really confused about the second line in the xml. How can it be displayed?

I tried below code..but don't know how to get the second line into xml..

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

Upvotes: 0

Views: 60

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1501163

If you're just trying to build that element, you want:

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

Upvotes: 2

Related Questions