Download presentation
Presentation is loading. Please wait.
Published byEsther West Modified over 8 years ago
1
1 11/29/05CS360 Windows Programming XML
2
2 11/29/05CS360 Windows Programming What is XML? XML: Extensible Markup Language HTML expresses appearance XML is designed to express raw attention No predefined tags All text Provides a common data format for exchanging information
3
3 11/29/05CS360 Windows Programming XML Nothing remarkable about XML However, there are numerous tools available for reading and writing XML What would you do if you were handed a large free-formatted text file?
4
4 11/29/05CS360 Windows Programming HTML What is HTML? Recipe Chocolate Chip Bars How does XML differ?
5
5 11/29/05CS360 Windows Programming XML vs. HTML Example: Shereen Khoja Chocolate Chip Bars Tags are invented to describe the content Tags need to make sense to be useful
6
6 11/29/05CS360 Windows Programming XML Language for describing data and the structure of data Start with an XML declaration This is a processing instruction
7
7 11/29/05CS360 Windows Programming XML Following the XML declaration is the document’s root element o Also called the document element …. Every document must have a document element
8
8 11/29/05CS360 Windows Programming Element Names Must conform to a set of rules o http://www.w3.org/TR/REC-xml http://www.w3.org/TR/REC-xml Consist of letters or underscore Followed by letters, digits, periods, hyphens, and underscores No spaces!
9
9 11/29/05CS360 Windows Programming Elements Building blocks of XML May contain o Data o Other elements o Or both Always delimited by start and end tags
10
10 11/29/05CS360 Windows Programming Example Gibson SG 1977 Tobacco Sunburst Rosewood Fender Stratocaster Black Rosewood
11
11 11/29/05CS360 Windows Programming Another Example Shereen Khoja Chocolate Chip Bars Dinner Dessert 2/3 C butter 2 C brown sugar 1 tsp vanilla 1 3/4 C unsifted all-purpose flour 1 1/2 tsp baking powder 1/2 tsp salt 3 eggs 1/2 C chopped nuts 2 cups (12-oz pkg.) semi-sweet choc. chips Preheat oven to 350 degrees. Melt butter; combine with brown sugar and vanilla in large mixing bowl. Set aside to cool. Combine flour, baking powder, and salt; set aside. Add eggs to cooled sugar mixture; beat well. Stir in reserved dry ingredients, nuts, and chips. Spread in greased 13-by-9-inch pan. Bake for 25 to 30 minutes until golden brown; cool. Cut into squares.
12
12 11/29/05CS360 Windows Programming XML Contains no information on layout Layout instructions will come from elsewheree
13
13 11/29/05CS360 Windows Programming Well Formed XML documents must be well formed o What does this mean? It must follow three rules o Document starts with an XML declaration o There is a root element in which all others are contained o All elements must be properly nested chocolate chips
14
14 11/29/05CS360 Windows Programming Well Formed XML Breaking any of the rules for XML well formed documents will result in a fatal error o What does this mean? Application will refuse to process XML XML documents can be very long How do we find errors?
15
15 11/29/05CS360 Windows Programming XML Parsers Solution: Use an XML parser Many free ones are available online o Lark: http://www.textuality.com/Lark/http://www.textuality.com/Lark/
16
16 11/29/05CS360 Windows Programming Valid XML Shereen Khoja Chocolate Chip Bars Dinner Dessert Melt butter; combine with, etc....
17
17 11/29/05CS360 Windows Programming Valid XML Valid XML must match a Document Type Definition (DTD) Who creates the DTD? o We do! DTD defines the tags that can be used in an XML documents It also defines the type of data within the tags
18
18 11/29/05CS360 Windows Programming Valid XML <!DOCTYPE list [ ]>
19
19 11/29/05CS360 Windows Programming Validating Parsers How can we test that an XML document is valid? Use a validating parser IE5 is an example of a validating parser
20
20 11/29/05CS360 Windows Programming XML in Action XML is used in many applications o Banks use proprietary systems to track transactions internally, but if they use a common XML format over the Web, then they'd be able to describe transaction information to another institution or an application (like Quicken or MS Money). Of course, they'd also be able to present the data in a pretty Web page.
21
21 11/29/05CS360 Windows Programming XML in Action Give an example of where you might use XML in an application….
22
22 11/29/05CS360 Windows Programming Summary Completed Chapter 12 Next Time o XML in.NET
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.