Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Converting XML to HTML

Converting XML to HTML

Scheduled Pinned Locked Moved XML / XSL
xmlhelpcsharphtml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Honan
    wrote on last edited by
    #1

    (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.

    M 1 Reply Last reply
    0
    • J John Honan

      (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.

      M Offline
      M Offline
      MS le Roux
      wrote on last edited by
      #2

      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.

      J 1 Reply Last reply
      0
      • M MS le Roux

        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.

        J Offline
        J Offline
        John Honan
        wrote on last edited by
        #3

        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[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups