public static void Main()
var xsl = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<xsl:stylesheet version=""1.0""
xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
<xsl:template match=""/"">
<xsl:for-each select=""root/book"">
<xsl:for-each select=""author"">
<xsl:value-of select=""current()""/>
<xsl:if test=""last() > position()"">
<xsl:for-each select=""title"">
<xsl:value-of select=""current()""/>
<xsl:if test=""last() > position()"">
var xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<title>book1Title</title>
<author>book1Author1</author>
<title>book2Title</title>
<author>book2Author1</author>
<author>book2Author2</author>
<title>book9Title1</title>
<title>book9Title2</title>
<author>book9Author</author>
string output = String.Empty;
using (StringReader srt = new StringReader(xsl))
using (StringReader sri = new StringReader(xml))
using (XmlReader xrt = XmlReader.Create(srt))
using (XmlReader xri = XmlReader.Create(sri))
var xslt = new XslCompiledTransform();
using (StringWriter sw = new StringWriter())
using (XmlWriter xwo = XmlWriter.Create(sw, xslt.OutputSettings))
xslt.Transform(xri, xwo);
Console.WriteLine(output);