Sample c# program to test xslt

 

If you don't have a version of vs (or any other xml editor) that supports debugging xslt you can use this simple program to test the xslt of the previous post.

Technorati Tags: , ,
   1: MemoryStream ms = new MemoryStream();
   2: XmlWriterSettings xws = new XmlWriterSettings();
   3: xws.Indent = true;
   4: XmlWriter xw = XmlWriter.Create(ms, xws);
   5:  
   6: // Load and transform
   7: XslCompiledTransform ctx = new XslCompiledTransform(false);
   8: ctx.Load(@"ATOM2Tree.xslt");
   9: ctx.Transform(textBlogUrl.Text, xw);
  10: xw.Flush();
  11: ms.Position = 0;
  12: StreamReader sr = new StreamReader(ms);
  13: textXml.Text = sr.ReadToEnd();
  14: ms.Position = 0;
  15: XPathDocument xd = new XPathDocument(ms);
  16: XPathNavigator xpn = xd.CreateNavigator();
  17: XPathNodeIterator iterator = xpn.Select("/");
  18: addNodes(treeView1.Nodes, iterator);

It loads the xml file and transform with the xslt, then shows the resulting xml in a text box and on a tree view.

You can load an ATOM feed from the Internet by specifying his url.

The project works with vs express.

posted @ mercoledì 15 agosto 2007 00:22

Print
Comments have been closed on this topic.
«aprile»
domlunmarmergiovensab
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011