XML Schema validation

Posted on 2006-03-28
Last Modified: 2013-11-19
I have a xml file that I load from an xml file (test.xml).  I also have a schema on my computer called (validate.xsd).  The xml file changes constantly, and it doesn't reference the schema file.  How do I load the xml file (preferably in an xmldocument object) and then validate the xml against the schema??
Question by:macros14
    LVL 14

    Expert Comment

    LVL 1

    Author Comment

    Yeah I figured it out

        Private Function LoadAndValidateXML(ByVal sXMLPath As String) As XmlDocument
            Dim doc As XmlDocument = New XmlDocument
            Dim tr As XmlTextReader = New XmlTextReader(sXMLPath)
            Dim reader As XmlValidatingReader = New XmlValidatingReader(tr)
            Dim xsc As Xml.Schema.XmlSchemaCollection = New Xml.Schema.XmlSchemaCollection
            xsc.Add(Nothing, "D:\apps\LendPro\Data\Schema\LendersProtectionFeedv4.xsd")

        End Function

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now