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.

«agosto»
domlunmarmergiovensab
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678