Converting XML to HTML
-
(Also crossposted to ASP.NET) I have an XML file which has the XSL file specified in the first line: 1380852 …. And the rest of the XML data follows …. I need to transform and output this as HTML. How can this be achieved in ASP.NET / VB.NET ? I have tried using the xmlTransform class, but it doesn’t seem to like the XSL reference embedded in the XML file. E.g: Dim myXslTransform As XslTransform Dim myXPathDocument As XPathDocument myXPathDocument = New XPathDocument("C:\test\test99.xml") myXslTransform = New XslTransform() ' myXslTransform.Load("") 'I don't have a separate .XSL stylesheet... Dim stWrite As System.IO.StringWriter = New System.IO.StringWriter() myXslTransform.Transform(myXPathDocument, Nothing, stWrite) Response.Write(stWrite.ToString) Gives the following error: 'xml:stylesheet' is an invalid name for a processing instruction. Line 1, position 3. Changing the first line of the XML file to read (dash instead of colon) gets rid of this error, but then I no longer have the XSL link, and it just outputs ‘raw’ XML! My end goal is to be able to read in multiple XML files in this format and output them to ONE browser page as HTML. Without having to load the XSL seperately. I mean, the XSL already ref'd in the XML, so I should surely be able to send it to the browser directly as HTML Any help is much appreciated. John.
-
(Also crossposted to ASP.NET) I have an XML file which has the XSL file specified in the first line: 1380852 …. And the rest of the XML data follows …. I need to transform and output this as HTML. How can this be achieved in ASP.NET / VB.NET ? I have tried using the xmlTransform class, but it doesn’t seem to like the XSL reference embedded in the XML file. E.g: Dim myXslTransform As XslTransform Dim myXPathDocument As XPathDocument myXPathDocument = New XPathDocument("C:\test\test99.xml") myXslTransform = New XslTransform() ' myXslTransform.Load("") 'I don't have a separate .XSL stylesheet... Dim stWrite As System.IO.StringWriter = New System.IO.StringWriter() myXslTransform.Transform(myXPathDocument, Nothing, stWrite) Response.Write(stWrite.ToString) Gives the following error: 'xml:stylesheet' is an invalid name for a processing instruction. Line 1, position 3. Changing the first line of the XML file to read (dash instead of colon) gets rid of this error, but then I no longer have the XSL link, and it just outputs ‘raw’ XML! My end goal is to be able to read in multiple XML files in this format and output them to ONE browser page as HTML. Without having to load the XSL seperately. I mean, the XSL already ref'd in the XML, so I should surely be able to send it to the browser directly as HTML Any help is much appreciated. John.
John Honan wrote: 'I don't have a separate .XSL stylesheet... And yet you're referencing "C:\test\MyXSLFile.xsl"? Isn't that your seperate stylesheet? :confused: If its a straightforward transform, you could try the XML control.
-
John Honan wrote: 'I don't have a separate .XSL stylesheet... And yet you're referencing "C:\test\MyXSLFile.xsl"? Isn't that your seperate stylesheet? :confused: If its a straightforward transform, you could try the XML control.
MS le Roux wrote: And yet you're referencing "C:\test\MyXSLFile.xsl"? Isn't that your seperate stylesheet? I should have been clearer on that. The separate stylesheet does exist, but I don't see why I have to go to the trouble of loading it if it's already referenced in the XML. IE can pick it up directly from the link in the XML, so why not .NET? However, from my research and some replies I've received, I don't think the XML classes in .NET can pick up an 'embedded' stylesheet like this, so I'll have to just load it separately anyway. Just trying the lazy approach! :zzz: John. www.silveronion.com[^]