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
LineNumber=2
LinePosition=1
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."
Source="System.Xml"
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()
            QuotesXmlDoc.Load(FileName)
            Loaded = True
            WebBrowser1.Navigate(FileName)

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

            '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)

            'tranformation
            Transform.Transform(QuotesXmlDoc, Nothing, xWriter)
            xWriter.Flush()
            xWriter.Close()
            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.

John

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.

Sincerely

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.