I'm building a windows app using C#. The goal is to merge portions of
multiple xml files into one.
I currently have an .xsl stylesheet that pulls in the required sections of
multiple xml files and combines them into one xml file. This xsl works
correctly.
I'm now trying to utilize this xsl in my C# application, along with the
required xml files, to merge them into the one document. Basically I'm
looking for a code example of how to apply the xsl style sheet to the
documents and create a single xml file.
I started working with the XslTransform.Transform method, but it's my
understanding that this only applies to a single xml document. My example
below works if the XSL stylesheet only references a single xml document, but
I need to be able to work with multiple documents:
string strXMLPath = "C:\\XML\\XML Files\\IS\\Management\\Management.xml";
string strXSLPath = "C:\\XML\\StyleSheets\\Application\\MgmtStyles.xsl ";
//Instantiate the XPathDocument class
XPathDocument xmlDoc = new XPathDocument(strXMLPath);
//Instantiate the XSLTransform class
XslTransform transform = new XslTransform();
transform.Load(strXSLPath);
XmlTextWriter writer = new XmlTextWriter("C:\\XML_FILES\\XML Data
Files\\IS\\Management\\TEMP.xml",null);
transform.Transform(xmlDoc,null,writer);
--
PK9