CG0119 Web Database Systems Parsing XML using SimpleXML.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
Native XML Database or RDBMS. Data or Document orientation If you are primarily storing documents, then a Native XML Database may be the best option.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
One acronym, one system: using the EMu API to connect your Collections Management System with your Content Management System 2009 European EMu Users Meeting,
CIS 4004: Web Based Information Technology Spring 2013
4/17/2015Comp Sci 3461 XML_2 Ch. 7. 4/17/2015Comp Sci 3462 XML Vocabularies  MathML  An application to parse, render, and edit MathML: Amaya 
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
Tutorial 16 Working with Dynamic Content and Styles.
AJAX & By – Anupama Sharma. Defining Ajax Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together.
Navigation Controls MacDonald Ch. 11 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
Senior Project – I.D. Math & Computer Science jsMath Equation Editor Dana Cartwright Advisors – Prof. Cervone & Prof. Striegnitz Editor Design -
PHP with XML Dequan Chen and Narith Kun ---Term Project--- for WSU 2010 Summer Course - CS366 s:
PHP and XML TP2653 Advance Web Programming. PHP and XML PHP5 – XML-based extensions, library and functionalities (current XAMPP PHP version is )
CS 174: Web Programming April 16 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
® IBM Software Group © 2006 IBM Corporation How to read/write XML using EGL This Learning Module shows how to utilize an EGL Library to read/write an XML.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Classes and Class Libraries Examples and Hints November 9,
JSP Standard Tag Library
In The Name Of God. Jhaleh Narimisaei By Guide: Dr. Shadgar Implementation of Web Ontology and Semantic Application for Electronic Journal Citation System.
XML, CFMX CFML & SQL XML Kevin Penny, MMCP
XML in SQL Server Overview XML is a key part of any modern data environment It can be used to transmit data in a platform, application neutral form.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
CG0119 Web Database Systems Using XPath to Navigate & Filter XML (via SimpleXML)‏
XML and its applications: 4. Processing XML using PHP.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
2-Day Introduction to Agent-Based Modelling Day 2: Session 8 Exploring Model Collections, NetLogo Lists, Further Resources.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
JavaScript, Fourth Edition
Intro to XML Originally Presented by Clifford Lemoine Modified by Box.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
Openadaptor XML Support Using openadaptor for XML processing Oleg Dulin,
ADO 2.5 Kamaljit Bath, Program Manager Data Access Group.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
Advanced PHP & RSS Utilizing XML, RSS, and PHP. XML (eXtensible Markup Language) XML is the language of all RSS feeds and subscriptions XML is basically.
Navigating the DOM with ExtJS By Aaron Conran. Document Object Model The Document Object Model or DOM is a standard to represent HTML, XHTML and other.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Intro to PHP Carl-Erik Svensson. What is PHP? PHP is a widely-used general-purpose scripting language that is especially suited for Web development and.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Lecture 3 : PHP5-DOM API UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
XML & AJAX Khaled Al-Sham’aa. XML The Extensible Markup Language (XML) is a general-purpose specification for creating custom markup languages. It is.
XML and Database.
© Anselm Spoerri Web Design Information Visualization Course Prof. Anselm Spoerri
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Declarative Languages and Model Based Development of Web Applications Besnik Selimi South East European University DAAD: 15 th Workshop “Software Engineering.
Loader Tutorial. Set Up Mapping Coding Scheme Values to LexGrid Model Creating a Loader – Step by Step Loader Review.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
What is it? –w3c standard for… Navigating through an XML document Filtering & finding information –Includes… Expressions for navigating to parts of an.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
{ XML Technologies } BY: DR. M’HAMED MATAOUI
Un</br>able’s MySecretSecrets
The XML Language.
Processing XML.
RichAnnotator: Annotating rich (XML-like) documents
Getting started with jQuery
XML and its applications: 4. Processing XML using PHP
Presentation transcript:

CG0119 Web Database Systems Parsing XML using SimpleXML

SimpleXML What is it? –A built in php library for manipulating xml files using an O-O approach –Allows you to read, write and query xml files. –A very simple interface hiding complex functionality.

SimpleXML Example – XML Document D Distinction M Merit P Pass F Fail grade.xml... SimpleXML represents this hierachical tree structure as a set of objects that ‘own’ or contain other objects. If we wanted to display all the grades we could iterate just through those elements like this: In psuedocode foreach grades->grade as currentgrade show currentgrade->gradeID show currentgrade->result end foreach documentdocument->grades document->grades->gradedocument->grades->grade->gradeID

Example – XML Document The aim of the example used in these slides is to list the grade data in a XHTML table e.g. FailF …… DistinctionD ResultID

SimpleXML Example – PHP Code Steps involved: 1.Create an instance of a simpleXMLElement class and load the XML file 2.Parse the XML by navigating through the document one node at a time REMEMBER: you are navigating a tree structure which is a hierarchy of parent/child nesting though SimpleXML represents this in O-O terms.

Step 1. Create simpleXML instance & load file and create XML // create a SimpleXML instance // two ways: // by passing a string to the constructor $xmlString = “…a whole xml document string”; $xml = new SimpleXMLElement($xmlString); // or by explicitly loading a file... $grades = simplexml_load_file(‘./grade.xml'); From now in the workshops we’ll only use the second method, explicitly loading a file.

Step 2. Navigate through the document foreach ($grades->grade as $currentgrade)‏ { $id = $currentgrade->gradeID; $result $currentgrade->result; echo “ $id $result \n”; } OR… foreach ($grades->grade as $currentgrade)‏ { echo “ {$currentgrade->gradeID} {$currentgrade->result} \n”; } simpleXML implements an iterator interface which means we can move through our xml document as though it were any other class object or an array. In this example we’re reading through each set of grade nodes assigning them to the variable $currentgrade. Copy the contents of the gradeID that’s in $currentgrade into a simple variable, just so that it’s easier to embed in a string Don’t copy into a simple variable but instead put the object method call in braces.

Summary SimpleXML is an O-O approach –More features for XML support than SAX (e.g. querying data with xpath, simple O-O interface, can add and subtract elements from the xml document tree.)‏ Use the references on the next page. They are good resources

Recommended Reading - PHP Manual: SimpleXML Functions Although a search on Google for simpleXML tutorial will give you lots of other sources.