Best way to read, modify, and write XML

前端 未结 8 1921
灰色年华
灰色年华 2021-02-05 10:39

My plan is to read in an XML document using my C# program, search for particular entries which I\'d like to change, and then write out the modified document. However, I\'ve bec

8条回答
  •  野的像风
    2021-02-05 11:02

    For the task in hand - (read existing doc, write, and modify in a formalised way) I'd go with XPathDocument run through an XslCompiledTransform.

    Where you can't formalise, don't have pre-existing docs or generally need more adaptive logic, I'd go with LINQ and XDocument like Skeet says.

    Basically if the task is transformation then XSLT, if the task is manipulation then LINQ.

提交回复
热议问题