I have been trying to import an XML file using a XSD to validate it. However when I try to import the XML file it fails. Then I compared the XML with the XSD file and found that the XML doesn't have all the elements specified in the XSD file. Is this what is causing the problem? Should an XML file necessarily use all the elements of the XSD file?
Consider the XSD below:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType>
<xs:element name="PersonInfo">
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
<xs:element name="title" type="xs:string"/>
<xs:element name="note" type="xs:string"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>
</xs:complexType>
</xs:element>
</xs:schema>
And I create an XML which contains only below elements:
<PersonInfo>
<name>Mark</name>
<title>XYZ</title>
<quantity>10</quantity>
<price>100</price>
</PersonInfo>
Is this a valid implementation of the XSD? When I try to import the XML file through loadXML() function, the function returns S_FALSE? I am not able to understand why the import is failing.