public void ConvertXmlToRss(string xmlFile, string schemaUri, string targetNamespace, out bool isConversionSuccessful, string userErrorFile = "") { if (!XmlValidator.IsXmlValid(@"..\..\..\books.xml", @"..\..\..\books.xsd", "http://library.by/catalog", @"..\..\..\error.txt")) { isConversionSuccessful = false; return; } isConversionSuccessful = true; }
static void Main(string[] args) { string xmlPath = Path.GetFullPath("/users/ruy/Documents/Training/XML/input.xml"); string xsdPath = Path.GetFullPath("/users/ruy/Documents/Training/XML/validationSchema.xsd"); XElement inputXml = XElement.Load(xmlPath); XDocument xmlDocument = new XDocument(inputXml); StringReader xmlSchemaDefinition = new StringReader(File.ReadAllText(xsdPath)); XmlValidator xmlValidator = new XmlValidator(); var isXmlValid = xmlValidator.IsXmlValid(xmlDocument, xmlSchemaDefinition); }
public void TestMethod1() { Assert.IsTrue(XmlValidator.IsXmlValid(@"..\..\..\books.xml", @"..\..\..\books.xsd", "http://library.by/catalog", @"..\..\..\error.txt")); }