CS 240 – Advanced Programming Concepts

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
The eXtensible Markup Language (XML) An Applied Tutorial Kevin Thomas.
XML: text format Dr Andy Evans. Text-based data formats As data space has become cheaper, people have moved away from binary data formats. Text easier.
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
XML Parsing Using Java APIs AIP Independence project Fall 2010.
Document Type Definitions
Java API for XML Processing (JAXP) CSE 4/586: Distributed Systems Department of Computer Science and Engineering University at Buffalo, New York Jia Zhao.
Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net.
23-Jun-15 HTML. 2 Web pages are HTML HTML stands for HyperText Markup Language Web pages are plain text files, written in HTML Browsers display web pages.
15-Jul-15 JSON. JSON example “JSON” stands for “JavaScript Object Notation” Despite the name, JSON is a (mostly) language-independent way of specifying.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language)  XML is a markup language for creating documents containing structured information.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
XML Syntax - Writing XML and Designing DTD's
XML Extensible Markup Language. What is XML? An infrastructure for describing text and data Developed by W3C(the World Wide Web Consortium)
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Session IV Chapter 9 – XML Schemas
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
XML and SVG from PQL By Dave Doulton Computing Services University of Southampton.
Unit 10 Schema Data Processing. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Reserved characters.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… XML Syntax v2.0.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
Review of XML Concepts Helpdesk Training. Review of XML Concepts What is an XML declaration? What is an XML Element What is Nesting? What is a Document.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
Unit 3 — Advanced Internet Technologies Lesson 10 — Introduction to XHTML.
OVERVIEW AND PARSING JSON. What is JSON JavaScript Object Notation Used to format data Commonly used in Web as a vehicle to describe data being sent between.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
X M L Extensible Markup Language It is a cross platform tool or a language to achieve data transfer between the cross platform. Note  1.XML is not a replacement.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML intro. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display.
Unit 4 Representing Web Data: XML
X M L Extensible Markup Language
Java XML IS
The XML Language.
CSCE 315 – Programming Studio Spring 2013
Chapter 7 Representing Web Data: XML
Creating an XML Document
Department of Computer Science Cal State East Bay, Hayward, CA
Allyson Falkner Spokane County ISD
Review of XML IST 421 Spring 2004 Lecture 5.
Extensible Markup Language (XML)
Presentation transcript:

CS 240 – Advanced Programming Concepts XML & JSON CS 240 – Advanced Programming Concepts

Background XML and JSON are two standard, textual data formats for representing arbitrary data XML stands for “eXtensible Markup Language” JSON stands for “JavaScript Object Notation” Both are commonly used in practice XML came first JSON, which uses JavaScript syntax, became popular for representing data in web applications and services If you’re using JavaScript, JSON is an obvious choice Both formats are reasonable choices, although some people have strong biases Most programming languages have libraries for parsing and generating both XML and JSON You should be familiar with both

Structure of XML Documents Header Root Element Start Tags / End Tags Element Contents Child Elements Text Both (mixed contents) Element Attributes Comments Entity References Examples (your browser will interpret some of the tags, so select “View Page Source”) Element-heavy Attribute-heavy Hybrid

Predefined Entities Entity name Character Specified By quot " " amp & & apos ' &apos; lt < gt >

Structure of JSON Documents Supported data types: Objects, Arrays, Numbers, Strings, Boolean, Null Objects delimited by { … } with comma-separated properties in between { “name”: “Bob”, “age”: 32, “alive”: true } Arrays delimited by [ … ] with comma-separated elements in between [ “testing”, 1, 2, 3, { “gpa”: 3.4 } ] Examples Verbose Simple

Parsing XML & JSON Data Most languages provide both XML and JSON parsers, so there’s no need to write your own Three Major Types of Parsers DOM Parsers Convert XML or JSON text to an in-memory tree data structure (the tree is called a DOM, or “document object model”) After running the parser to create a DOM, traverse the DOM to extract the data you want Stream Parsers Tokenizers that return one token at a time from the XML or JSON data file Serializers / Deserializers Use a library to convert from XML or JSON to Java Objects (and vice versa) Jackson for XML Gson or Jackson for JSON

JSON Parsing Examples Source File: cd_catalog.json Domain Object: CD DOM Parser Example JsonDomParserExample.java Stream Parser Example JsonStreamParserExample.java

JSON Parsing Examples (cont.) Deserialization using the Gson library from Google Simple Deserialization Example Source File: cd_catalog_simple.json Domain Objects: Catalog, CD JsonSimpleObjectDeserializationExample.java Complex Deserialization Example Source File: cd_catalog.json JsonObjectDeserializationExample.java

XML Parsing Examples Source File: cd_catalog.xml Domain Object: CD DOM Parser Example XmlDomParserExample.java Stream Parser Example XmlStreamParserExample.java

XML Parsing Examples (cont.) Deserialization using Jackson Source File: cd_catalog.xml Domain Objects: Catalog, CD XmlObjectDeserializationExample.java

Generating XML & JSON Data Programs often need to generate (or create) XML and JSON data You can print XML or JSON data yourself (it’s just text), but it’s better to use a library that handles tricky special cases like escaping special characters) Three Ways to Generate XML or JSON Create DOM tree in memory, and then tell the tree to write itself to text Write the data as a stream, one token at a time Use a “serializer” class that converts Java objects to XML or Json

JSON Generation Examples Domain Objects: CDFactory (used to generate Java objects to be converted), Catalog, CD DOM Generator Example JsonDomGenerationExample.java Stream Generator Example JsonStreamGenerationExample.java

JSON Generation Examples (cont.) Serialization using Gson Simple Serialization Example Domain Objects: CDFactory, Catalog, CD JsonSimpleObjectSerializationExample.java Complex Deserialization Example JsonObjectSerializationExample.java

XML Generation Examples Domain Objects: CDFactory, Catalog, CD DOM Generator Example XmlDomGenerationExample.java Stream Generator Example XmlStreamGenerationExample.java

XML Generation Examples (cont.) Serialization using the Jackson library Domain Objects: CDFactory, Catalog, CD XmlObjectSerializationExample.java