CG0119 Web Database Systems Using XPath to Navigate & Filter XML (via SimpleXML)‏

Slides:



Advertisements
Similar presentations
CG0119 Web Database Systems Parsing XML using SimpleXML.
Advertisements

CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
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?
XPath Eugenia Fernandez IUPUI. XML Path Language (XPath) a data model for representing an XML document as an abstract node tree a mechanism for addressing.
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
XSLT & XPATH. From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must.
A note on generating text with the xsl:value-of instruction.
XML, XPATH and JDOM ICW Lecture 9 Hasan Qunoo. Recap -XML document structure. -XML parsers. -JDOM: -Package Info. -Load An XML document. -Saving An XML.
M.Sc. of Advanced Software Engineering CO7206 System Reengineering XPath Many Slides are by Georgios Koutsoukos.
Cornell CS 502 More XML XML schema, XPATH, XSLT CS 502 – Carl Lagoze – Cornell University.
Introduction to XSLT & its use in Grainger Library full-text & metadata projects Thomas G. Habing Grainger Engineering Library Presentation to ASIS&T,
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
SD2520 Databases using XML and JQuery
PHP and XML TP2653 Advance Web Programming. PHP and XML PHP5 – XML-based extensions, library and functionalities (current XAMPP PHP version is )
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Navigating XML. Overview  Xpath is a non-xml syntax to be used with XSLT and Xpointer. Its purpose according to the W3.org is  to address parts of an.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
Xpath Xlink Xpointer Xquery Sources:
1/17 ITApplications XML Module Session 7: Introduction to XPath.
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
Introduction to XPath Web Engineering, SS 2007 Tomáš Pitner.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
XML and its applications: 4. Processing XML using PHP.
CSE3201/CSE4500 Information Retrieval Systems
XPath XPath is used to navigate through elements and attributes in an XML document. XPath is a major element in W3C's XSLT standard - and XQuery and XPointer.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
1 XPath XPath became a W3C Recommendation 16. November 1999 XPath is a language for finding information in an XML document XPath is used to navigate through.
Session II Chapter 2 – Chapter 2 – XSLhttp://
Extensible Markup and Beyond
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Date : 3/3/2010 Web Technology Solutions Class: Application Syndication: Parse and Publish RSS & XML Data.
Database Systems Part VII: XML Querying Software School of Hunan University
PHP Constructs Advance Database Management Systems Lab no.3.
Lecture 3 : PHP5-DOM API UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
JSTL The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
XPath. XPath, the XML Path Language, is a query language for selecting nodes from an XML document. The XPath language is based on a tree representation.
More XML XPATH, XSLT CS 431 – February 23, 2005 Carl Lagoze – Cornell University.
Session II Chapter 3 – Chapter 3 – XPath Patterns & Expressions Chapter 4 – XPath Functions Chapter 15 – XPath 2.0http://
CSE3201/CSE4500 XPath. 2 XPath A locator for items in XML document. XPath expression gives direction of navigation.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
What is it? –w3c standard for… Navigating through an XML document Filtering & finding information –Includes… Expressions for navigating to parts of an.
1 XPath. 2 Agenda XPath Introduction XPath Nodes XPath Syntax XPath Operators XPath Q&A.
5 Copyright © 2004, Oracle. All rights reserved. Navigating XML Documents by Using XPath.
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Querying and Transforming XML Data
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML stands for Extensible Markup Language.
Querying XML XPath.
Querying XML XPath.
XML and its applications: 4. Processing XML using PHP
More XML XML schema, XPATH, XSLT
Presentation transcript:

CG0119 Web Database Systems Using XPath to Navigate & Filter XML (via SimpleXML)‏

XPath What is it? –w3c standard for… Navigating through an XML document Filtering & finding information –Includes… Expressions for navigating to parts of an XML document The standard includes functions (e.g. for string & date manipulation)‏ Used in XSLT – we used some XPath path expressions last week…!!!

XPath Expressions What are they? –Path expressions are a means of selecting nodes (or sets of nodes) from an XML document –They consist of… A path to the nodes/node sets A predicate (optional)‏ Syntax –Without a predicate: Nodenames, separated by a forward slash (/)‏ –Predicates: Predicates are placed inside [ ]

Example xml document P Anabela Domingues P 2004 M Ann Devon U student.xml Root nodeChild of root node Children of student

Examples: XPath Expressions What would be the path expression to navigate to the startYear node? What would be the path expression to select the startYear node where the startYear = 2002? ‘/students/student/startYear’ ‘/students/student/startYear[. = “2002”]’ --- OR --- ‘/students/student[startYear = “2002”]/startYear’ has more details on & examples of path expressions

Example: Multiple Predicates What would be the path expression to select student nodes where the startYear = 2002 and the studyTypeIdD= U? '/students/student[startYear=2003][studyTypeID = "U"]' has more details on & examples of path expressions

XPath & simpleXML Example The aim of the example used in the following slides is to list data in a XHTML table for all students who started at University in 2002 e.g. Fiona Murray M … … Ann Devon M Name Student Code

XPath & simpleXML – PHP Code Steps involved in this example: 1.Create an instance of a simpleXML class by loading the XML file 2.Construct the query expression 3.Call the XPath method to execute the query 4.Loop through the result set

Steps 1 to 3: simpleXML & XPath Objects // Create a new simplexml instance loading xml file $studentsXML = simplexml_load_file('student.xml'); // Construct an XPath expression, // including a predicate in this instance. $qry = '/students/student[startYear = "2002"] '; // call the simplexml xpath method $students = $studentsXML->xpath($qry);

Step 4: Loop Through Query Result Set // iterate through the students returned by the xpath query foreach ($students as $student) { } echo " {$student->studentCode} \n"; echo " {$student->forename} "; echo "{$student->surname} \n"; echo " \n"; echo " {$student->studentCode} \n"; echo " {$student->forename} "; echo "{$student->surname} \n"; echo " \n"; echo " Student Code Name \n"; echo " \n";

Summary XPath is a w3c standard for –Navigating through an XML document –Filtering & finding information Path expressions navigate to a particular node or node-set and they may include predicates

Recommended Reading - Xpath tutorial - XPath in 5 paragraphs! - w3schools XPath tutorial & reference *