Amit Kumar Srivastava
Amit Kumar Srivastava
• To: Amit
• From: AJAY
• Heading: Reminder
• <note>
<to>Amit</to>
<from>Ajay</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
About Note.xml
• The XML above is quite self-descriptive:
• against DTD
• against XSD
• DTD (Document Type Definition) and XSD (XML Schema Definition)
are used to define XML structure.
employee.xml using DTD
• <?xml version="1.0"?>
• <!DOCTYPE employee SYSTEM "employee.dtd">
• <employee>
• <firstname>vimal</firstname>
• <lastname>jaiswal</lastname>
• <email>[email protected]</email>
• </employee>
XML Schema
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
• The Schema above is interpreted like this:
• <xs:element name="note"> defines the element called "note"
• <xs:complexType> the "note" element is a complex type
• <xs:sequence> the complex type is a sequence of elements
• <xs:element name="to" type="xs:string"> the element "to" is of type
string (text)
• <xs:element name="from" type="xs:string"> the element "from" is of
type string
• <xs:element name="heading" type="xs:string"> the element "heading"
is of type string
• <xs:element name="body" type="xs:string"> the element "body" is of
type string
Quiz
• Is XML case sensitive?
• Can we use graphics in XML?
• Is XML meant to be a replacement of HTML?
Next day
• Tree
• Syntax
• Element
• Attribute