Little experience used by Transform. XSLT file:
If there is XML Version = "1.0" encoding = "UTF-8"?> It will become the result of the first part of the first part: XML Version = "1.0" Encoding = "UTF-8"?> GHJ1976@9cbs.netDearbook Cash on delivery Order
.....
but:
If there is no XML Version = "1.0" encoding = "UTF-8"?> ghj1976@9cbs.netDearbook cash on delivery order
This is not: XML Version = "1.0" encoding = "UTF-8"?>.
The code called at this time is:
Private void button2_click (object sender, system.eventargs e) {string savefile = @ "c: /1.htm"; string xmlfile = @ "e: /myworks/test/trans/testwin/order.xml"; string xslfile = @ "E: /myworks/test/trans/testwin/order.xslt"; if (file.exists (savefile)) {file.delete (savefile);} filestream fs = new filestream (Savefile, FileMode.create); XmLDocument xmlDoc = new XmlDocument (); xmlDoc.Load (XmlFile); XPathNavigator nav = xmlDoc.DocumentElement.CreateNavigator (); XslTransform xmlXsl = new XslTransform (); xmlXsl.Load (XslFile); xmlXsl.Transform (nav, null, fs, NULL); XMLXSL = NULL; NAV = null; xmldoc = null; fs.close (); fs = null;} Later, according to Googidea's views, the code is changed to:
Private void button1_click (object sender, system.eventargs e) {string savefile = @ "c: /1.htm"; string xmlfile = @ "e: /myworks/test/trans/testwin/order.xml"; string xslfile = @ "E: /myworks/test/trans/testwin/order.xslt"; if (file.exists (savefile)) {file.delete (Savefile);} filestream fs = new filestream (savefile, filemode.create);
XmlTextWriter Writer = New XmlTextWriter (fs, system.text.encoding.default); Writer.Formatting = formatting.indented;
XmlDocument xmlDoc = new XmlDocument (); xmlDoc.Load (XmlFile); XPathNavigator nav = xmlDoc.DocumentElement.CreateNavigator (); XslTransform xmlXsl = new XslTransform (); xmlXsl.Load (XslFile); xmlXsl.Transform (nav, null, writer , NULL); XMLXSL = NULL; NAV = NULL; XMLDOC = NULL; fs.close (); fs = null;}
There is no such problem.
Similarly, the thoughts are provided, and then the
The root node of the result tree has an element child. The expanded-name of the first element child of the root node (that is, the document element) of the result tree has local part "html" (in any combination of uppercase and lowercase) and a null namespace URI. Any text nodes preceding the first element child of the root node of the result tree contain only white space characters. Otherwise, the default output method is "xml". Zee provided.
Specific discussion process
http://blog.joycode.com/ghj/posts/4080.aspx