LINQ to XML techniques: adding a processing instruction
September 19, 2016 Leave a comment
In this post we saw how to add a declaration to an XML document. A well-formatted XML document starts with a declaration whose main function is to declare formally that the upcoming document is of the XML type. The XDeclaration object helps us to easily add a declaration to an XML document. Note that the XDocument.ToString method does not print the declaration for some reason so we need to print it separately if needed.
In this post we’ll see how to add a processing instruction to an XML document.