We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

XML Schema validation

Medium Priority
267 Views
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??
Comment
Watch Question

Author

Commented:
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")
        reader.Schemas.Add(xsc)

        doc.Load(reader)
    End Function
Commented:
PAQed with points refunded (500)

GranMod
Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.