Adding a new XML node to a last one of the same sort

I have an Excel table saved as a XML file, so there are some rows there. All I want is to add a new row to the last one using C#.

Structure:

<?mso-application progid="Excel.Sheet"?>
<Workbook>
  <DocumentProperties>
    ...
  </DocumentProperties>
  <OfficeDocumentSettings>
    ...
  </OfficeDocumentSettings>
  <ExcelWorkbook>
    ...
  </ExcelWorkbook>
  <Styles>
    ...
  </Styles>
  <Worksheet ss:Name="TDSheet">
    <Table>
      <Column>
        ...
      </Column>
        ...
      <Column>
        ...
      </Column>
      <Row>
        ...
      </Row>
      <!-- HIER SHOULD APPEAR MY NEW ROW -->
    </Table>
  </Worksheet>
</Workbook>

I use XmlDocument class.

Jon Skeet
people
quotationmark

It looks like you just need to find the relevant Table element, then append a new Row element to that. For example, using LINQ to XML, assuming there is only one Table element:

var doc = ...; // XDocument.Load or whatever
var table = doc.Descendants("Table").First();
table.Add(new XElement("Row", ...));

If there can be more than one Table element, you need to work out how to find the right one - which we can't tell at the moment from your question.

people

See more on this question at Stackoverflow