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. Web Development
  3. ASP.NET
  4. Convert XML file

Convert XML file

Scheduled Pinned Locked Moved ASP.NET
xmlcomsysadminhelptutorial
4 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.
  • S Offline
    S Offline
    shapper
    wrote on last edited by
    #1

    Hello, Could someone tell me how to convert a XML file into another XML file using a XSL file with a parameter? I created the code to do it, and it seems ok, but it is not working. Could somebody, please, help me out? I am on this for days. My code is as follows: Dim webSiteMap As XmlDocument = New XmlDocument webSiteMap.Load(HttpContext.Current.Server.MapPath("~/INPUT.XML")) Dim googleXsl As XslCompiledTransform = New XslCompiledTransform googleXsl.Load(HttpContext.Current.Server.MapPath("~/CONVERT.XSL")) Dim googleXslArguments As XsltArgumentList = New XsltArgumentList googleXslArguments.AddParam("Domain", "", "http://www.domain.com") Dim webSiteMapStream As MemoryStream = New MemoryStream googleXsl.Transform(webSiteMap, googleXslArguments, webSiteMapStream) context.Response.Clear() context.Response.ContentType = "text/xml; charset=utf-8" context.Response.Write(Encoding.UTF8.GetString(webSiteMapStream.GetBuffer)) context.Response.End() Thanks, Miguel

    N 1 Reply Last reply
    0
    • S shapper

      Hello, Could someone tell me how to convert a XML file into another XML file using a XSL file with a parameter? I created the code to do it, and it seems ok, but it is not working. Could somebody, please, help me out? I am on this for days. My code is as follows: Dim webSiteMap As XmlDocument = New XmlDocument webSiteMap.Load(HttpContext.Current.Server.MapPath("~/INPUT.XML")) Dim googleXsl As XslCompiledTransform = New XslCompiledTransform googleXsl.Load(HttpContext.Current.Server.MapPath("~/CONVERT.XSL")) Dim googleXslArguments As XsltArgumentList = New XsltArgumentList googleXslArguments.AddParam("Domain", "", "http://www.domain.com") Dim webSiteMapStream As MemoryStream = New MemoryStream googleXsl.Transform(webSiteMap, googleXslArguments, webSiteMapStream) context.Response.Clear() context.Response.ContentType = "text/xml; charset=utf-8" context.Response.Write(Encoding.UTF8.GetString(webSiteMapStream.GetBuffer)) context.Response.End() Thanks, Miguel

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      shapper wrote:

      but it is not working.

      You'll have to provide more detail than this. Is an exception being thrown? Is the transform not happening? Is it happening but you don't get the expected results?


      only two letters away from being an asset

      S 1 Reply Last reply
      0
      • N Not Active

        shapper wrote:

        but it is not working.

        You'll have to provide more detail than this. Is an exception being thrown? Is the transform not happening? Is it happening but you don't get the expected results?


        only two letters away from being an asset

        S Offline
        S Offline
        shapper
        wrote on last edited by
        #3

        Han, C# for me is fine. I will do any conversion to VB.Net. Anyway, I tried your suggestion and it still doesn't work. Anyway, I am posting my XSL and XML files as well the new version of my VB.NET (I also post the conversion to C# using the VB.NET to C# converter available in http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx) The error I am getting is: XML Parsing Error: not well-formed Location: http://localhost:1132/GaragemRamos 2006a/Google Line Number 2, Column 62: Thanks, Miguel --------- XSL CODE --------- --------- VB.NET Code --------- ' Create ASP.NET web site map Dim webSiteMap As XmlDocument = New XmlDocument ' Load ASP.NET's site map webSiteMap.Load(HttpContext.Current.Server.MapPath("~/Web.sitemap")) ' Create google xsl document Dim googleXsl As XslCompiledTransform = New XslCompiledTransform ' Load google xml document googleXsl.Load(HttpContext.Current.Server.MapPath("~/SiteMap.xsl")) ' Create xsl arguments list Dim googleXslArguments As XsltArgumentList = New XsltArgumentList googleXslArguments.AddParam("WebSiteUrl", "", "http://www.mydomain.com") ' Create the ASP.NET's site map memory stream

        S 1 Reply Last reply
        0
        • S shapper

          Han, C# for me is fine. I will do any conversion to VB.Net. Anyway, I tried your suggestion and it still doesn't work. Anyway, I am posting my XSL and XML files as well the new version of my VB.NET (I also post the conversion to C# using the VB.NET to C# converter available in http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx) The error I am getting is: XML Parsing Error: not well-formed Location: http://localhost:1132/GaragemRamos 2006a/Google Line Number 2, Column 62: Thanks, Miguel --------- XSL CODE --------- --------- VB.NET Code --------- ' Create ASP.NET web site map Dim webSiteMap As XmlDocument = New XmlDocument ' Load ASP.NET's site map webSiteMap.Load(HttpContext.Current.Server.MapPath("~/Web.sitemap")) ' Create google xsl document Dim googleXsl As XslCompiledTransform = New XslCompiledTransform ' Load google xml document googleXsl.Load(HttpContext.Current.Server.MapPath("~/SiteMap.xsl")) ' Create xsl arguments list Dim googleXslArguments As XsltArgumentList = New XsltArgumentList googleXslArguments.AddParam("WebSiteUrl", "", "http://www.mydomain.com") ' Create the ASP.NET's site map memory stream

          S Offline
          S Offline
          shapper
          wrote on last edited by
          #4

          Please, Could someone help me out? I just posted my entire code. I still wasn't able to solve my problem Thank You Very Much, Miguel

          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