Hi Dmitri,
May I know which child are you using for TransformToString() method, I'm testing with the following code and it works fine for me, if you are trying to convert the first node to string, it will fail with COM exception because it is not a real XML node, only
the XML Style Sheet Declaration.
XSLT code from W3School, valid.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
C# code in App
public async void kkk()
{
// Read XSLT
StorageFile xslFile = await KnownFolders.MusicLibrary.GetFileAsync("1.xslt");
Windows.Data.Xml.Dom.XmlDocument xslDoc = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(xslFile);
// Apply XSLT on XML
Windows.Data.Xml.Xsl.XsltProcessor processor = new Windows.Data.Xml.Xsl.XsltProcessor(xslDoc);
if(xslDoc.HasChildNodes())
{
string aaa = processor.TransformToString(xslDoc.ChildNodes[1]);
}
}
--James
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.