xml documents
play

XML Documents 5 May 2016 OSU CSE 1 e X tensible M arkup L anguage - PowerPoint PPT Presentation

XML Documents 5 May 2016 OSU CSE 1 e X tensible M arkup L anguage A textual document format used all over the web is XML Used to represent hierarchically organized data for ease of use both by humans and computers Had its


  1. XML Documents 5 May 2016 OSU CSE 1

  2. e X tensible M arkup L anguage • A textual document format used all over the web is XML – Used to represent hierarchically organized data for “ease of use” both by humans and computers – Had its origins in SGML (Standard Generalized Markup Language) from the 1980s – Became a standard in the late 1990s 5 May 2016 OSU CSE 2

  3. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN="978-1-118-06331-6" webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 3

  4. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN="978-1-118-06331-6" webISBN="1-118063-31-7" An XML pubDate="Dec 20 2011"> declaration is the first line of well- <author>Cay Horstmann</author> formed XML file. <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 4

  5. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN="978-1-118-06331-6" This is not webISBN="1-118063-31-7" part of the pubDate="Dec 20 2011"> actual <author>Cay Horstmann</author> document/file! <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 5

  6. Example XML Document/File This is an <?xml version="1.0" encoding="UTF-8"?> author <book printISBN="978-1-118-06331-6" element . webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 6

  7. Example XML Document/File This is a <?xml version="1.0" encoding="UTF-8"?> start tag <book printISBN="978-1-118-06331-6" for an author element. webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author> Cay Horstmann</author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 7

  8. Example XML Document/File This is an <?xml version="1.0" encoding="UTF-8"?> end tag <book printISBN="978-1-118-06331-6" for that author element. webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann </author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 8

  9. Example XML Document/File The content <?xml version="1.0" encoding="UTF-8"?> for this author <book printISBN="978-1-118-06331-6" element is everything webISBN="1-118063-31-7" between its start and end tags. pubDate="Dec 20 2011"> <author> Cay Horstmann </author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 9

  10. Example XML Document/File If the author <?xml version="1.0" encoding="UTF-8"?> element had no <book printISBN="978-1-118-06331-6" content, then you webISBN="1-118063-31-7" might find this, or… pubDate="Dec 20 2011"> <author></author> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 10

  11. Example XML Document/File … or you might find <?xml version="1.0" encoding="UTF-8"?> a single <book printISBN="978-1-118-06331-6" self-closing tag webISBN="1-118063-31-7" like this. pubDate="Dec 20 2011"> <author /> <title> Java for Everyone: Late Objects </title> ... </book> 5 May 2016 OSU CSE 11

  12. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN="978-1-118-06331-6" webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> Java for Everyone: Late Objects </title> This is a ... title </book> element. 5 May 2016 OSU CSE 12

  13. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN="978-1-118-06331-6" webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> Java for Everyone: Late Objects </title> This is a ... book </book> element. 5 May 2016 OSU CSE 13

  14. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN ="978-1-118-06331-6" webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> This is the Java for Everyone: Late Objects name of an </title> attribute ... of the book element. </book> 5 May 2016 OSU CSE 14

  15. Example XML Document/File <?xml version="1.0" encoding="UTF-8"?> <book printISBN=" 978-1-118-06331-6 " webISBN="1-118063-31-7" pubDate="Dec 20 2011"> <author>Cay Horstmann</author> <title> This is the Java for Everyone: Late Objects value </title> of the ... printISBN attribute. </book> 5 May 2016 OSU CSE 15

  16. Recursive Structure • An XML document (without the XML declaration in the first line) is made up of: – A top-level element – A string of zero or more child elements of the top-level element, each of which is exactly like the top-level element of an XML document • Notice the similarity to a tree: the structure of an XML document is also recursive • Information it represents is hierarchical 5 May 2016 OSU CSE 16

  17. Can You Find All The Errors? <?xml version="1.0" encoding="UTF-8"?> <pony> <unicorn mark="three lozenges"> <color>cyan</unicorn> </color> <unicorn>Twilight<color>cyan</color>Sparkle</unicorn> <unicorn mark="dolphins" version="G4" /> </pony> <dragon> <youth>Spike </dragon> 5 May 2016 OSU CSE 17

  18. Resources • Big Java , Section 23.1 (but not the rest of Chapter 23) – https://library.ohio-state.edu/record=b8540788~S7 • Wikipedia: XML – http://en.wikipedia.org/wiki/XML 5 May 2016 OSU CSE 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend