How to use XSD <any> Element in XML
In this article I am going to explain about XSD <any> element in XML.
XSD The <any> Element in XML
XSD <any> Element as such type of element in XML by which we can extend XML document with element. Its not specified by the Schema.
Example
In following example we have XML scheme name is Emp.xsd its show the declaration of "Employee" element.
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Fname" type="xs:string"/>
<xs:element name="Address" type="xs:string"/>
<xs:any minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element
|
In this Example we have another schema manager.xsd its show the declaration of "Manager" element.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://dotnetheaven.com"
xmlns="http://https://dotnetheaven.com"
elementFormDefault="qualified">
<xs:element name="manager">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
In this example we ahve another schema Company.xsd that used two different schema component.
<?xml version="1.0" encoding="ISO-8859-1"?>
<Employee xmlns="http://www.microsoft.com"
xmlns:xsi=="http://https://dotnetheaven.com"
xsi:schemaLocation="http://www.microsoft.com Emp.xsd
http://="dotnetheaven.com" manager.xsd">
<Employee>
<Fname>Jown</Fname>
<Address>Delhi</Address>
<Manager>
<name>Dipak</name>
</Manager>
</Employee>
<Employee>
<Fname>jown</Fname>
<Address>Delhi</Address>
</Employee>
</Employee>
|
Further Readings
You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here