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. C#
  4. convert XML to HTML

convert XML to HTML

Scheduled Pinned Locked Moved C#
xmlhtmlquestion
2 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.
  • M Offline
    M Offline
    marky777
    wrote on last edited by
    #1

    Hello I need to convert an XML doc (which has an XSL applied to it) to an HTML doc. I tried this, but it does not allow me to specify a URL as a path: //1) Load the Xml document XPathDocument myXPathDoc = new XPathDocument("C:\\SSW55P12902365.XML"); //2) Load the Xsl file XslCompiledTransform myXslTrans = new XslCompiledTransform(); //XslTransform myXslTrans = new XslTransform(); myXslTrans.Load("C:\\Style.xsl"); //3) Create a stream for output XmlTextWriter myWriter = new XmlTextWriter("http://www.SpecifiedURL/SSW55P12902365.html", null); //4) Perform the actual transformation myXslTrans.Transform(myXPathDoc,null,myWriter); If I use a folder path on the hard drive instead of the URL it works. Is there any other (free) way to do this conversion? Thanks M

    J 1 Reply Last reply
    0
    • M marky777

      Hello I need to convert an XML doc (which has an XSL applied to it) to an HTML doc. I tried this, but it does not allow me to specify a URL as a path: //1) Load the Xml document XPathDocument myXPathDoc = new XPathDocument("C:\\SSW55P12902365.XML"); //2) Load the Xsl file XslCompiledTransform myXslTrans = new XslCompiledTransform(); //XslTransform myXslTrans = new XslTransform(); myXslTrans.Load("C:\\Style.xsl"); //3) Create a stream for output XmlTextWriter myWriter = new XmlTextWriter("http://www.SpecifiedURL/SSW55P12902365.html", null); //4) Perform the actual transformation myXslTrans.Transform(myXPathDoc,null,myWriter); If I use a folder path on the hard drive instead of the URL it works. Is there any other (free) way to do this conversion? Thanks M

      J Offline
      J Offline
      Joachim Kerschbaumer
      wrote on last edited by
      #2

      the dirty way : string xmldata = new Webclient().DownloadString("http://your.desired.url/file.xml"); XPathDocument myXPathDoc = new XPathDocument(xmldata); ... //go on with your stuff. maybe you want to structure it, add exception handling or use it in an async manner, but it´s probably the right direction if you want to use a url instead of a local file.

      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