Is it possible to replace the root element of an XDocument?
I currently have a document that looks like:
<ArrayOfCompletedInvoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CompletedInvoice>
<Invoice>1</Invoice>
...
</CompletedInvoice>
</ArrayOfCompletedInvoice>
I want it to look like:
<ns0:CompletedInvoices xmlns:ns0="http://myNamespace">
<CompletedInvoice>
<Invoice>1</Invoice>
...
</CompletedInvoice>
</ns0:CompletedInvoices>
I know I can replace the name with XDocument.Root.Name, but I am stuck seeing if there's a way to replace the entire element?
XDocumentwith a new root and simply copy over the first levelXElements from your original document? (Not my downvote, btw.) - João Mendes