Subject: ASP.NET 1.0 with VB.NET
Posted By: Steve P. Post Date: 11/16/2003 10:45:57 PM
This book has been a very useful reference.  I am now using it in conjunction with Beginning XML (2nd Edition).  I wanted to use ASP.NET's ValidatingReader to validate the samples in Beginning XML.  On Page 798 of ASP.NET Namespace is a program to do this.  It uses a DropDownList to select the XML file, but hardcodes the schema file.  I thought I could also use a drop down list for the schema file.  But I can't get it to work.  I've used OnClick events to a) load the files and b) validate the xml file. When I validate, I get an error that: "Object reference not set to an instance of an object."  It apparently refers to the XMLValidatingReader.  THe code snippet is:

Dim strSchemaPath As String = Left(strCurrentPath, _
                          InStrRev(strCurrentPath, "\")) & _
                          SelSchemaFile.SelectedItem.Value
                                
                     
                          'create new XmlTextReader object and load Xml document
              objXTReader = New XmlTextReader(strXmlPath)
              objValidator = New XmlValidatingReader(objXTReader)
             objValidator.ValidationType = ValidationType.Schema
    
              Dim objSchemaCol As New XmlSchemaCollection()
             objSchemaCol.Add("", strSchemaPath)
    
             'assign the schema collection to the XmlValidatingReader
             objValidator.Schemas.Add(objSchemaCol)

The error is in the last line.  Any help is appreciated on this or if you know another way to dynamically select the XML and schema file for validation.

Steve P.


Go to topic 6554

Return to index page 1004
Return to index page 1003
Return to index page 1002
Return to index page 1001
Return to index page 1000
Return to index page 999
Return to index page 998
Return to index page 997
Return to index page 996
Return to index page 995