Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Error Validating XML with DTD in asp.net


Message #1 by "toby steele" <tobysteele@h...> on Fri, 26 Jul 2002 16:40:23 +0000
I am trying to validate an xml file in my code. To debug and get working, I am using an xml file that I
validate against a DTD in XMLSpy, so I know it is validated correctly. When I try to run the code I get an exception. 


Here?s my code: 



Dim oReader As XmlTextReader, oVReader As XmlValidatingReader 



oReader = New XmlTextReader(Server.MapPath("test.xml")) 

oVReader = New XmlValidatingReader(oReader) 

oVReader.ValidationType = ValidationType.DTD 

Dim oXML As New XmlDocument() 

Try 

oXML.Load(oVReader) 

Catch eException As Exception 

Response.Write(eException.Message & "") 

Response.Write(eException.StackTrace & "") 

Finally 

oVReader.Close() 

oReader.Close() 

End Try 





I get this error: This is an unexpected token. Expected 'WHITESPACE'. Line 83, position 104. 



The stack track is: 

at System.Xml.Schema.DtdParser.ParseAttDefaultDecl() 

at System.Xml.Schema.DtdParser.ParseAttlist() 

at System.Xml.Schema.DtdParser.ParseDtdContent() 

at System.Xml.Schema.DtdParser.ParseDocTypeDecl() 

at System.Xml.Schema.DtdParser.Parse() 

at System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner) 

at System.Xml.XmlTextReader.ParseTag() 

at System.Xml.XmlTextReader.ParseRoot() 

at System.Xml.XmlTextReader.Read() 

at System.Xml.XmlValidatingReader.ReadWithCollectTextToken() 

at System.Xml.XmlValidatingReader.Read() 

at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) 

at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) 

at System.Xml.XmlDocument.Load(XmlReader reader) 

at HR_XML.ValidationTest.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\HR-XML\ValidationTest.aspx.vb:line 29 



I am really stuck because I can?t figure out where the error is coming from 


Thanks for any input 

MSN Photos is the easiest way to share and print your photos: Click Here

  Return to Index