Download presentation
Presentation is loading. Please wait.
1
Extensible Markup Language (XML)
CS422 Dick Steflik
2
What is XML A Markup Language for giving a text document contextual structure parentage is Standard Generalized Markup Language (SGML; ISO 8879) specify a documents structure and attributes, not processing should ne declarative a set of rules for encoding documents that is both human and machine readable
3
Things to note in the example
Every tag is paired with an ending tag end tags have same name preceded with "/" tag pairs constitute xml entities Tag are in lower case by convention (XML doesn't care about case) Documents must be "well formed" tags may be nested one inside of another (never cross matched) every opening tag must have a closing tag
4
Tag Attributes Every tag may have a set of attributes
specified as part of the tag as either name/value pairs (ex. id="abc") Attributes must be quoted keywords ( ex. noform) attributes specify additional information about the tag attributes are separated by one or more spaces commas will generate errors
5
Attribute example <message <subject>Another XML Example</subject> <text> This is the message body. </text> </message>
6
XML Prolog XML files always start out with a prolog line
<?xml version="1.0"> other attributes: encoding – identifies the character set used to encode the data standalone – identifies that the document stands alone i.e doesn't require any external references.
7
Example <?xml version="1.0" encoding="ISO8859-1" standalone="yes"> <message <subject>Another XML Example</subject> <text> This is the message body. </text> </message>
8
Comments in XML files <! >
9
Processing Instructions
Since XML is a portable document format, the same document may be processed by a number of applications, this processing can be specified in the file Each instruction should be of the form: <?target instructions ?> target – the name of the processing application instruction – a string of characters that specify the processing commands or parameters
10
Why is XML Important? Not a binary format
can be transtorted accross a network easily easy to create manually or programatically makes debugging easier can describe very complex objects easy to store in a database more scalable than binary
11
Data Identification Since the tags describe the structure of the data, it makes the same data more usable by multiple applications looking at the previous example: it is easily searchable by a search program easily displayable by a viewer easy to store in a database
12
Stylability For applications where rendering is important (word processors, browsers, publishing) use Extensible Stylesheet Language (XSL) XSLT XSL-FO XPATH
13
Inline reusability Unlike HTML, XML documents can include other inline documents this allows the construction of very complex objects from: other simpler objects other hosts
14
XML Parsers To make the data from an XML document useful it must be parsed out of the document. This can be easily done two ways SAX (Simple API for XML) java api that parses xml and retrieves the data as the tags are encountered DOM (Document Object Model) as an xml or xhtml document is loaded into the browser it is parsed into a document tree and then via javascript made available for processing More on DOM and SAX later in the course
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.