You must Sign In to post a response.
  • Category: XML

    How to check the file validation..?

    how to check the xml file is validate or not

    string[] files = Directory.GetFiles(@"A:\\123", "*.xml", SearchOption.AllDirectories);


    how to check the xml file of files[0] is valid or not ......
  • #740638
    Validates the XmlDocument against the XML Schema Definition Language schemas contained in the Schemas property.You will find the article on your topic at msdn.microsoft.com/en-us/library/ms162371%28v=vs.110%29.aspx
    http://stackoverflow.com/questions/3465335/how-to-validate-an-xml-document

  • #740670
    in what sense you want to validate it ? want to parse it against XML schema then you can use following code link
    you can use XMLReader for xml parsing.
    http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx
    OR
    you want to check the formatting of XML, then you can use XMLDocumentClass and use 'load' method
    see below code snippet

    XMLDocument xmlDom;
    Try
    {
    xmlDom = new XMLDocument();
    xmlDom.load("XMl file path");
    //xml parse successfully
    }
    Catch(Exception ex)
    {
    //xml is not parsed successfully
    }
    Finally
    {
    xmlDom = null;
    }

    hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments