Click to See Complete Forum and Search --> : How to Validate a XML file in ASP page


lilu
August 17th, 2003, 07:04 PM
Hi ,

I want validate a XML file using a schema in my ASP page.

I'm doing something like this:

------------------------------------------------------------------------------------Dim MyDom
set MyDom = Server.CreateObject("MSXML2.DOMDocument")
MyDom.load(server.MapPath("c:\temp\book.xml"))
if (MyDom.validate() = 0)
Response.write("valid xml document")
else
Response.write("invalid xml document")
end if

------------------------------------------------------------------------------------
Here validate() function always retruns error code :0xC00CE224. As per MSDN this means "Validate failed because a DTD or schema was not specified in the document."

But I have linked the schema file in my xml(book.xml) file like this :

<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="c:\temp\book.xsd">

so it should have got that schema file. Here both .xml and .xsd file are in c:\temp folder.

Please let me know if I'm doing anything wrong here.

Lilu.

Satishpp
August 19th, 2003, 12:26 PM
Could you post a sample of the XML and XSD files?

Or maybe you can use the files shown in the link here and test if it works with this.

http://www.w3schools.com/schema/schema_howto.asp

Satish