Convert XML file
-
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
-
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
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
-
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
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
-
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