Hi All,

I am writing a program that saves quotes for writers to an xml file. Well I save my data to the xml file, but when I go to load the document I get this exception thrown at runtime.

System.Xml.Xsl.XslLoadException was unhandled
Message="Stylesheet must start either with an 'xsl:stylesheet' or an 'xsl:transform' element, or with a literal result element that has an 'xsl:version' attribute, where prefix 'xsl' denotes the 'http://www.w3.org/1999/XSL/Transform' namespace."
SourceUri="file:///C:/Users/John-Ellis/Documents/Visual Studio 2008/Projects/Assignment 6/QTR/QTR/bin/Debug/QTR.xml"

Please see my code below for the load button.

Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Imports System.Data.SqlClient

Public Class SearchQuotes
    Dim QuotesXmlDoc As XmlDocument
    Dim Loaded As Boolean
    Dim FileName As String

    Private Sub btnLoadQuotes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadQuotes.Click
        Dim od As New OpenFileDialog
        od.Filter = "XML Files(*.XML;)|*.XML"

        If od.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = od.FileName
            QuotesXmlDoc = New XmlDocument()
            Loaded = True

            'create the transform object
            Dim Transform As XslCompiledTransform = New XslCompiledTransform()

            'create xml writer
            Dim Settings As New XmlWriterSettings
            Settings.CloseOutput = True
            Dim xWriter As XmlWriter = XmlWriter.Create("C:\Users\John-Ellis\Documents\Visual Studio 2008\Projects\Assignment 6\QTR\QTR\Quotes.xml", Settings)

            Transform.Transform(QuotesXmlDoc, Nothing, xWriter)
            WebBrowser2.Navigate("C:\Users\John-Ellis\Documents\Visual Studio 2008\Projects\Assignment 6\QTR\QTR\Quotes.xml")
        End If

    End Sub

I'm at a bit of a loss, any help would be greatly appreciated.

Thanks very much.


It seems that the current content of the QTR.xml file is in a bad format.

Please post it here to help you to verify it.


This article has been dead for over six months. Start a new discussion instead.