Tech
Forums
Jobs
Books
Events
Live
Learn
More
Training
Interviews
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
upload xml file to validate xsd file already store in mvc
olaitan temi
Sep 23 2015 5:42 AM
451
Reply
already create my controller
public ActionResult Index()
{
Validations Validate = new Validations();
string isValidate = Validate.ValidateXMlUsingXSD();
if (isValidate == string.Empty)
isValidate = "xml is well formed according to XSd.";
ViewBag.Validate=isValidate;
return View();
}
]
}
and the service code
namespace ValidateXmlUsingXsd1.Service
{
public class Validations
{
public string ValidateXMlUsingXSD()
{
try
{
string xmlPath = @"C:\Users\topcrat\Documents\Visual Studio 2013\Projects\ValidateXmlUsingXsd1\ValidateXmlUsingXsd1\XML\XMLFile1.xml";
string xsdPath = @"C:\Users\topcrat\Documents\Visual Studio 2013\Projects\ValidateXmlUsingXsd1\ValidateXmlUsingXsd1\XSD\XMLSchema1.xsd";
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null, XmlReader.Create(xsdPath));
XmlReader xmlReader = XmlReader.Create(xmlPath, settings);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
return string.Empty;
}
catch(Exception e )
{
return e.Message;
}
}}
i want to be able to upload my xml file via view and validate it against the schema.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Timer in mvc4?
How to Intigrate with twitter