I have to make an xml like this and post to a url on fly
<Student>
<Name>John</Name>
<Age>17</Age>
<Marks>
<Subject>
<Title>Maths</Title>
<Score>55</Score>
</Subject>
<Subject>
<Title>Science</Title>
<Score>50</Score>
</Subject>
</Marks>
</Student>
string marksxml = "<Marks><Subject><Title>Maths</Title><Score>55</Score></Subject><Subject><Title>Science</Title><Score>50</Score></Subject></Marks>";
XDocument doc = new XDocument(new XElement("Student",
new XElement("Name", "John"),
new XElement("Age", "17")));
What needs to be done to embed the string marksxml into XDocument?
Just parse marksxml
as an XElement
and add that:
XDocument doc = new XDocument(
new XElement("Student",
new XElement("Name", "John"),
new XElement("Age", "17"),
XElement.Parse(marksxml)
);
)
See more on this question at Stackoverflow