I'd like to use XDocument (or any other similar library) to generate some XHTML. Unfortunately, the nested tags are ending up on the same level, not within one another. Can someone help me with this simple issue?
What I have so far:
var html = new XDocument(
new XElement("div", new XAttribute("class", "MyTable"),
new XElement("table",
new XElement("thead"),
new XElement("tr"),
new XElement("th", "Test"))));
This results in the following:
<div class="MyTable">
<table>
<thead />
<tr />
<th>Test</th>
</table>
</div>
Here's the layout I would like to achieve:
<div class="MyTable">
<table>
<thead>
<tr>
<th>Test</th>
</tr>
</thead>
</table>
</div>