Presentation is loading. Please wait.

Presentation is loading. Please wait.

Javascript & jQuery XML.

Similar presentations


Presentation on theme: "Javascript & jQuery XML."— Presentation transcript:

1 Javascript & jQuery XML

2 Introducing XML XML (eXtensible Markup Language) XML vs HTML
A language used to create structured documents XML vs HTML XML is designed to transport and store data (carry) HTML was designed to display data (show) Shares common structure with HTML documents Elements are indicated with markup tags that contain textual content; element names are descriptive A markup tag can contain attributes that describe a feature of the element, and a single root element contains all other elements in the document

3 Introducing XML XML does not DO anything. XML was created to structure, store, and transport information. The following example is a note to Taylor, from Janice, stored as XML <note> < to>Taylor</to> < from>Janice</from> < heading>Reminder</heading> < body>Don't forget me this weekend!</body> < /note>

4 XML Tree Structure With XML You Invent Your Own Tags
the XML language has no predefined tags XML documents form a tree structure that starts at "the root" and branches to "the leaves". <root> <child> <subchild> .

5 Introducing XML XML declaration Single root element (students)
It defines the XML version (1.0) and the encoding used (UTF-8). Single root element (students) Student, name, and photo elements and the id and grade attributes provide information about individual students

6 Syntax Rules Must have closing tags Case sensitive tags
Proper tag nesting Must have a Root element Attributes must be quoted Uses HTML comments Special symbols > < & ‘ “ Use entity references: < >

7 Syntax Rules Comments are similar to HTML comment
White-space is Preserved in XML Naming rules XML elements must follow these naming rules: Names can contain letters, numbers, and other characters Names cannot start with a number or punctuation character Names cannot start with the letters xml (or XML, or Xml, etc) Names cannot contain spaces Any name can be used, no words are reserved

8 XML Elements An XML element is everything from (including) the element's start tag to (including) the element's end tag An element can contain: other elements text attributes or a mix of all of the above <bookstore> < book category="CHILDREN"> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> < /book> < /bookstore>

9 XML attributes XML elements can have attributes.
Attributes provide additional information about an element. <file type="gif">computer</file>

10 XML Elements vs. Attributes
Take a look at these examples: < person sex="female"> <firstname>Anna</firstname> <lastname>Smith</lastname> < /person> < person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname> < /person> Some of the problems with using attributes are: attributes cannot contain multiple values (elements can) attributes cannot contain tree structures (elements can) attributes are not easily expandable (for future changes) Attributes are difficult to read and maintain Use elements for data, and attributes for information that is not relevant to the data


Download ppt "Javascript & jQuery XML."

Similar presentations


Ads by Google