How to use XSD <anyAttribute> Element in XML

In this article I am going to explain about XSD <anyAttribute> in XML.
  • 3310

XSD The  <anyAttribute>  Element in XML

XSD <any> Element as such type of element in XML by which we can extend XML document with Attribute. Its not specified by the Schema.


In following example we have XML scheme name is Emp.xsd its show the declaration of "Employee" element by using the <anyAttribute>  elemet. We can add any number of attribute to "Employee" element.

<xs:element name="Employee">



      <xs:element name="Fname" type="xs:string"/>

      <xs:element name="Address" type="xs:string"/>






In this Example we have another schema doce.xsd its show the declaration of "marriedStatus" element.


<?xml version="1.0" encoding="iso-8859-1"?>

<xs:schema xmlns:xs=""





  <xs:attribute name="marriedStatus">


      <xs:restriction base="xs:string">

        <xs:pattern value="married |Unmarried"/>







In this example we have another schema Company.xsd that used two different schema component.


<?xml version="1.0" encoding="ISO-8859-1"?>


<Employee xmlns=""


xsi:SchemaLocation=" Emp.xsd doce.xsd">


  <Employee gender="Married">





  <Employee gender="Unmarried">






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


© 2020 DotNetHeaven. All rights reserved.