XML using XSL
-
i am using xml to import data to my web page. Information is displaying but xsl style sheet is not applying please tell me, whats the problem .... Please my code is : Dim xmlPath As String = Server.MapPath("XMLFile.xml") Dim xslPath As String = Server.MapPath("XSLTFile.xsl") Dim fs As FileStream = New FileStream(xmlPath, FileMode.Open,FileAccess.Read) Dim reader As StreamReader = New StreamReader(fs, Encoding.UTF8) Dim xmlReader As XmlTextReader = New XmlTextReader(reader) 'Instantiate the XPathDocument Class Dim doc As XPathDocument = New XPathDocument(xmlReader) '//Instantiate the XslTransform Class Dim xslDoc As XslCompiledTransform = New XslCompiledTransform() xslDoc.Load(xslPath) Dim sw As StringWriter = New StringWriter() xslDoc.Transform(doc, Nothing, sw) ' //Close Readers reader.Close() xmlReader.Close() Response.Write(sw.ToString()) Please help me... :(( Feroze
-
i am using xml to import data to my web page. Information is displaying but xsl style sheet is not applying please tell me, whats the problem .... Please my code is : Dim xmlPath As String = Server.MapPath("XMLFile.xml") Dim xslPath As String = Server.MapPath("XSLTFile.xsl") Dim fs As FileStream = New FileStream(xmlPath, FileMode.Open,FileAccess.Read) Dim reader As StreamReader = New StreamReader(fs, Encoding.UTF8) Dim xmlReader As XmlTextReader = New XmlTextReader(reader) 'Instantiate the XPathDocument Class Dim doc As XPathDocument = New XPathDocument(xmlReader) '//Instantiate the XslTransform Class Dim xslDoc As XslCompiledTransform = New XslCompiledTransform() xslDoc.Load(xslPath) Dim sw As StringWriter = New StringWriter() xslDoc.Transform(doc, Nothing, sw) ' //Close Readers reader.Close() xmlReader.Close() Response.Write(sw.ToString()) Please help me... :(( Feroze
Hi Feroze! Why aren't you using the XML-Control (found in the Toolbox)? With this you just need to apply the XML-Source and the transformation file. e.g: Dim xmlDoc As New XmlDocument() xmlDoc.Load("your path to the xml-data goes here") With yourXmlControl .Document = xmlDoc .TransformSource = "your path to the xsl-file goes here" End with This is all what needs to be done. - walter