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"?>
<Address>
  <City>Beverly Hills</City>
  <State>CA</State>
  <Zip>90210</Zip>
</Address>

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:complexType>
      <xs:sequence>
        <xs:element name="City" type="xs:string" />
        <xs:element name="State" type="xs:string" />
        <xs:element name="Zip" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Open in new window

XML-Validator.zip
XMLC#.NET Programming

Avatar of undefined
Last Comment
Russ Suter

8/22/2022 - Mon