Thursday, December 31, 2015

XML- LOOK

Hope all of you had rocked 2015!  Last day of the year, many might be getting ready to party hard and few with resolutions to make it big in their careers.  All the best and make the most of it.

                                                                   XML: LOOK

<?xml version="1.0"? >  Declaration
<!.. My first XML document.. > comment

<message status="urgent" type="friendly">
 start tag  ...attribute...
<text>Hello Joy</text>
<subject>How are you</subject>
</message>

The above document contains start tag, attribute, sub-elements,declaration and comments.


Root is the outmost element in the above case <message> 
Elements can contain child elements ( e.g., message contains text and subject)

Attribute-( message status="urgent" type="friendly"
Name-value pair separated by "=" sign... similar to attributes in the HTML tags.
Attributes of elements are defined in the starting tag not at the end tag.

XML has become useful in three major areas
1) Putting data on the web
2) Storing/Sending system data
3) Exchanging data between applications.

Data described using markup language
Each individual piece of information is "marked up" A marker shows the meaning of the associated data- <name>Joy</name>
        Start tag-content-End tag

A unit of data to which a meaning has been attached is called an "element". An element consists of 'Start tag', 'content','End tag'.

When required an "attribute" can be described in the start tag of an element showing more detailed information to be assigned to the data.
<name id="26">Joy Joshi</name>
            .attribute.

Mark: Tag names are case-sensitive.They come in two flavours 
1) Paired - <title>Joy to the world</title>

2) Empty: A single tag with no closing tag- Elements require no data
Data can be provided through tag attributes
Ex:  <customer number="CUST123" name="Joy"/>
                                                                                 Empty tag
Attribute value are always quoted strings...passing application must convert to other data types.
Can begin with and contain any characters except (Digits, whitespace,punctuation etc.,)

Example using tag attributes:

<customer number="CUST123" 
status="VIP"
account manager="EMP007"
<name>Joy</name>
</customer>


Customer has three attributes
1) Number
2) Status
3) Account Manager

                                                              COMMENTS

XML uses comments like other languages.

Notes to a human being-Not interpreted by parsers.

                                           <!.. comment.. >

Rule for using comments
1) No comments before XML declaration in the first line
2) No comments within other markups
3) Don't use "--" ( two hyphens) within comment text.
4) No nested comments.













No comments:

Post a Comment

Note: Only a member of this blog may post a comment.