Avatar of Russ Suter
Russ Suter

asked on 

(XML) The element is not declared

This is a super simple application (code attached). Its only purpose is to validate an XML document against and XSD schema. I've included a sample XML document and sample XSD schema for reference.

The program runs. It validates. Unfortunately, in the included example all I get back is "The 'Address' element is not declared." It IS declared! I declared it. WTF?

While on the subject I have a related question. How can I modify the code so it will evaluate the entire document for errors and not just give up after the first one it encounters?
<?xml version="1.0" encoding="utf-8"?>
  <City>Beverly Hills</City>

Open in new window

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Address">
        <xs:element name="City" type="xs:string" />
        <xs:element name="State" type="xs:string" />
        <xs:element name="Zip" type="xs:string" />

Open in new window

XMLC#.NET Programming

Avatar of undefined
Last Comment
Russ Suter

8/22/2022 - Mon