My requirement is to update an XML file (some elements identified via a parameter, with new attribute values again identified via a paramenter).
I am using XSLT to do the same via C# code.
My code is as below:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(f_Xslt);
XmlReader xr = XmlReader.Create("SourceXML.xml");
XmlWriter xw = XmlWriter.Create("DestinationXML.xml");
XsltArgumentList argsList = new XsltArgumentList();
argsList.AddParam("", "", "");
...
...
...
xslt.Transform(xr, argsList, xw);
In my XSLT file, I first copy all elements, attributes. And then based on <xsl:template match = ... />
, I update the elements, attr/values.
All this is saved to Destination.xml
What if I want all of this to happen on Source.xml itself.
Of course, the easiest solution(or my solution so far) is to replace the Source.XML with Destination.XML after I complete the XSLT.Transform successfully.