School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.

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

What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
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 & Data Structures for the Internet Yingcai Xiao.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
History Leading to XHTML
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.
Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Tutorial 11 Creating XML Document
XML Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
XML: What, Why, When & How? Hope Greenberg Center for Teaching & Learning June 11 & 18.
Introduction to XML This material is based heavily on the tutorial by the same name at
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.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML What is XML? XML v.s. HTML XML Components Well-formed and Valid Document Type Definition (DTD) Extensible Style Language (XSL) SAX and DOM.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
August Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
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,
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
Lecture 6 XML DTD Content of.xml fileContent of.dtd file.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
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 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.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
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.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
Martin Kruliš by Martin Kruliš (v1.1)1.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
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:
XML Introduction to XML Extensible Markup 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”
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
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.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
Unit 4 Representing Web Data: XML
Java XML IS
XML in Web Technologies
Chapter 7 Representing Web Data: XML
Web Programming Maymester 2004
Javascript & jQuery XML.
CS 240 – Advanced Programming Concepts
Allyson Falkner Spokane County ISD
Extensible Markup Language (XML)
Presentation transcript:

School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data

School of Computing and Information Systems CS 371 Web Application Programming Data Encoding transporting data from script to another data needs to be organized fixed length, comma delimited or proprietary formats can be efficient but structure must be “known” by sender and receiver DBMS is not an option because they cannot be accessed by clients need a portable format where the structure is independent of the scripts

School of Computing and Information Systems CS 371 Web Application Programming Exensible Markup Language subset of SGML enforces well-formed tags (or elements) tags are not predefined users can define structure of data allows groups to agree to a standard and easily enforce it. tags are nested, self-described and case sensitive

School of Computing and Information Systems CS 371 Web Application Programming Data Flow XML document (data) XML document (data) DTD or schema Validator Sending script Receiving script Parser

School of Computing and Information Systems CS 371 Web Application Programming Structure of an XML Document elements (tags) and attributes like XHTML to be well-formed all elements must be terminated elements must be case sensitive elements must be properly nested must have a root element attribute values must be quoted white space is preserved declarative tag

School of Computing and Information Systems CS 371 Web Application Programming XML Example Thomas Cruise Saginaw Jack Nicholson Grand Rapids root tag attributesname and homeTown are children of student element text node

School of Computing and Information Systems CS 371 Web Application Programming Rules for Elements names composed of letters, numbers and other chars cannot start with a number or punctuation cannot start with xml (XML, etc) no spaces - also avoid "." can have content attributes attributes can have values values must be quoted

School of Computing and Information Systems CS 371 Web Application Programming Content normally everything is parsed (#PCDATA) built-in entities: &, <, " &xx; (&39; is a single quote) use to pass data through parser as simple text

School of Computing and Information Systems CS 371 Web Application Programming Examples well-formed Grand Valley text not quite well-formed first bullet second Grand Valley Jason Mikey

School of Computing and Information Systems CS 371 Web Application Programming Validation To be well-formed a document must also conform to a dtd (document type definition) dtd defines the structure of an xml doc: name of root element what is valid/invalid content for an element what attributes can be used type of data (parsed or unparsed) dtd can be internal or external xml schema is alternative to dtd many xml validators – just google it

School of Computing and Information Systems CS 371 Web Application Programming DTD Construction reference in xml file external: internal prologue in dtd file (

School of Computing and Information Systems CS 371 Web Application Programming DTD Construction (cont) defining elements: content models elements can be empty can have text can have other elements avoid use of ANY ex: student must have id, name and grade

School of Computing and Information Systems CS 371 Web Application Programming DTD Construction Recurrence comma means strict order | (pipe) is like or + is one or more, * is zero or more ? means that the element is optional use parens () for grouping

School of Computing and Information Systems CS 371 Web Application Programming DTD Construction Examples in the xml file contents can include any parsed data must have name, id, major and any # of minors name, any number of hobbies or sports and age contains parsed data or name and address

School of Computing and Information Systems CS 371 Web Application Programming DTD Attribute Types ex: type can be CDATAcharacter data (en1|en2|…)one from the list IDa unique identifier IDREFreferences an ID NMTOKENvalid XML name ENTITYvalue is an entity (&st;) a few others…

School of Computing and Information Systems CS 371 Web Application Programming DTD Attribute Types (cont) defVal (default value) can be: valuean actual value #REQUIREDattribute is required #IMPLIEDnot required #FIXEDattribute value is fixed

School of Computing and Information Systems CS 371 Web Application Programming Caveats hosting an xml file – make sure it has executable permissions

School of Computing and Information Systems CS 371 Web Application Programming XML Parsers parsers are used to traverse xml tree tree-based (DOM) loads entire document into memory random access, readable and writable contains objects: doc, node, nodeList, error stream-based (SAX) fires events when encountering new entity ex: fires startElement(“author”,attr) DOM and SAX parsers in.net, java, etc.

School of Computing and Information Systems CS 371 Web Application Programming xml parsers javaScript already familiar with dom parser (getElementsByTagName) see no sax parser (why not?). (3 rd party) PHP dom parser – see php.net/manual/en/book.simplexml.php sax parser – see php.net/manual/en/book.xml.php

School of Computing and Information Systems CS 371 Web Application Programming XSL: Stylesheets for XML XSL is like a template used with an xml file like xhtml with special tags for trans. xml use XPATH for navigation select (student) // selects all child nodes select (/student[0]) // first student from root elements: template element defines scope of xml

School of Computing and Information Systems CS 371 Web Application Programming JSON basic syntax {“var1”:val,”var2”:val…} just like array initialization in javascript (hmm) in php use json_encode($object) to create a JSON string in javascript: var myObject = JSON.parse(text, reviver); where reviver is opt function called for every key and value