如何在文件上传ASP.Net MVC上使用XSLT

时间:2012-05-29 21:13:05

标签: xslt

我需要能够在文件上传时上传KML文件,使用XSLT将其转换为GML,然后将其保存到我的SQL 2008数据库。我不知道怎么做。任何帮助表示赞赏。

这是我到目前为止的代码:

public ActionResult Create(GeoRegion georegion, HttpPostedFileBase Polygon)
    {
        if (ModelState.IsValid)
        {

            if (Polygon.ContentLength > 0)
            {
                var fileName = Path.GetFileName(Polygon.FileName);
                var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                Polygon.SaveAs(path);

            }




            db.GeoRegions.Add(georegion);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        return View(georegion);
    }

1 个答案:

答案 0 :(得分:0)

// Create the XslCompiledTransform object
var transform = new XslCompiledTransform(); 

// Load the stylesheet file
transform.Load(xslFilePath);                

// Transform the XML file and store the output
transform.Transform(sourceFilePath, targetFilePath);    

http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx