Presentation is loading. Please wait.

Presentation is loading. Please wait.

Well Formed XML The basics. A Simple XML Document Smith Alice.

Similar presentations


Presentation on theme: "Well Formed XML The basics. A Simple XML Document Smith Alice."— Presentation transcript:

1 Well Formed XML The basics

2 A Simple XML Document Smith Alice

3 XML Tags Starting Tag Ending Tag Alice

4 Empty Elements Some tags contain no data Often this is because all their content is in the form of attributes These can be closed in the regular way with an opending and closing tag, or they can end with />

5 Case Sensitivity XML is case sensitive does not match with the closing tag or This makes it easier for programs to parse

6 XML Trees Employees Employee Name Lastname “Smith Firstname “Alice” Status ( dept=“Accounting” Paytype=“Salary”)

7 Parents and Children In the diagram on the previous slide, the employee element is the parent to the name and the status elements name is the parent of the firstname and lastname elements firstname and lastname are children of the name element. Etc.

8 Root Element All XML documents must have a root element that encloses all the other elements (like HTML in an HTML document)... Employees is the root element in our xml example

9 Attributes An element can have 0 to several attributes. The values of an attribute must be enclosed in quotes (single or double)

10 XML Names Element and attribute names follow the same rules XML names my contain any alphanumeric letter They can also include any of three punctuation marks ◦ The hyphen – ◦ The underscore __ ◦ The period.

11 XML Names Cont. XML names must begin with a letter or the underscore The cannot begin with a number There is no limit to the length of the names but they cannot contain spaces Any string beginning with “xml” (lower or upper case) is reserved

12 Entity References XML entities are almost identical to HTML entities. You use them to substitute for illegal or potentially confusing characters XML defines 5 entities & < > " &apos;

13 CDATA Sections When you need to quote large sections of say HTML code you can use CDATA sections rather than entities for each character <![CDATA[ ]]>

14 Comments XML comments are just like HTML comments They begin with You cannot put a comment in an element And the double -- is forbidden in the text of the comment since it would confuse the parser

15 Processing Instructions Processing instructions contain information to be used by other applications such as browsers Processing instructions begin with The XML declaration is a not a processing instruction

16 XML Declaration or Prolog Version (currently 1.0 or 1.1) Standalone (“yes” means there is no DTD or schema definition for this document) Encoding (the particular Unicode or ISO character encoding)

17 Checking for Well-Formedness Every start tag must have an end tag or be self closed Elements may not overlap (proper nesting) There must be exactly one root element Attribute values must be quoted An element may not have two attributes with the same name Comments and processing instructions may not appear inside elements No unescaped < or & signs may occur in the element’s or attribute’s character data


Download ppt "Well Formed XML The basics. A Simple XML Document Smith Alice."

Similar presentations


Ads by Google