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.

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

HTML popo.
CG0119 Web Database Systems Parsing XML using SimpleXML.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
Java Script Session1 INTRODUCTION.
PHP Introduction.
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.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 11 Working with Operators and Expressions
Guide To UNIX Using Linux Third Edition
JavaScript, Third Edition
Chapter 14 Introduction to HTML
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
INTERNET APPLICATION DEVELOPMENT For More visit:
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 Working with Data Types and Operators. 2 Using Variables and Constants The values stored in computer memory are called variables The values, or data,
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
Utilizing XML in ColdFusion MX by Attila Domokos.
Date : 3/3/2010 Web Technology Solutions Class: Application Syndication: Parse and Publish RSS & XML Data.
INTRODUCTORY Tutorial 1 Using HTML Tags to Create Web Pages.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
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.
Tutorial 13 Validating Documents with Schemas
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
PHP Programming with MySQL Slide 3-1 CHAPTER 3 Working with Data Types and Operators.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
XML Extensible Markup Language
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
Radoslav Georgiev Telerik Corporation
PHP using MySQL Database for Web Development (part II)
Web Basics: HTML/CSS/JavaScript What are they?
This is the cover slide..
Unit M Programming Web Pages with
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
PHP Introduction.
Introduction to JavaScript
JavaScript an introduction.
A second look at JavaScript
PHP.
Training & Development
Introduction to JavaScript
Web Programming and Design
Web Programming and Design
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

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 a way of separating data from aesthetics XML is a “poor man’s” database XML is similar to HTML, but you get to create the tags “Self-describing” data

XML Presentation XML can be used to present content in different formats: XHTML/HTML, PDF, Graphics, Mobile Devices, Text, MS Office

XML Syntax ELEMENT CHILD ELEMENT ATTRIBUTE … VALUE Matthews Darell TEXT (Darell) START TAG JavaScript Lessons Neilson, Jason END TAG ELEMENT CHILD ELEMENT ATTRIBUTE … VALUE Matthews Darell TEXT (Darell) START TAG JavaScript Lessons Neilson, Jason END TAG

XML as a Database XML data organized into elements, attributes, and values (similar to tables, fields, and elements) Works great for storing around 50 or less attribute/value pairs Often used in JS slideshows (1 XML for settings, 1 for photos used) and Flash animations (1 XML for settings telling the flash movie what to do)

XPath XPath is a language which allows us to quickly access information in an XML document based on our knowledge of its structure /child::student/child::student[$number=‘0001’]Example: movie.xml, movie.php, actor.php

XML Address Book Create addressbook.php, which lists your name as an, then a horizontal rule Create addressbook.xml, which will include 5 people and their contact information (name, address, city, state, zip, phone, ) Create a drop-down list populated with names pulled from addressbook.xml using SimpleXMLElements. Once the user selects a name, they click “Search” to bring up that person’s contact information on a page called contact.php. The contact.php page should display that person’s contact information, again being pulled from the XML file using the API, in an organized table. All PHP pages should be styled (in any manner you wish) using an external CSS file.

XML Address Book addressbook.php contact.php

SimpleXML PHP API that allows PHP to interact with XML Create an XML document, then use PHP to parse the document for filtering / querying. SimpleXMLElement is the PHP parsing function Since RSS feeds use XML to describe data in the feed, we can use PHP to parse that feed for our usage, all we need is the feed address and some knowledge of the XML structure. Item, title, description, link Podcasts are RSS feeds with attachments

Feed Parsing View the page View the XML source code (notice the element, child elements, attributes, and values) Most RSS feeds follow the same general structure and element/attribute naming convention Use PHP to grab the contents of the feed and place them into an HTML document for styling Use PHP to grab the contents of the feed and place them into an HTML document for styling

Feed Styling and Output Once you have PHP gathering the feed data, now use HTML and PHP to style the output simplexmlelementdemoCIS115.php PHP “foreach” statement to loop and grab each feed article and put it into a list where the title is a link to the article channel -> item as $item) { ?> link; ?>"> title; ?> PHP “foreach” statement to loop and grab each feed article and put it into a list where the title is a link to the article channel -> item as $item) { ?> link; ?>"> title; ?>

Parsing Other RSS Feeds Find an RSS feed, podcast, or vodcast online with an accessible XML feed source page Use PHP to gather the feed data, then a “foreach” statement to parse each child element of the XML feed Use HTML to style the output of the PHP parsing into an ordered or unordered list

PHP Data Types & Operators PHP doesn’t require you to specify data type You can initialize and declare variables in one line $variable = “some value or string”; echo $variable; Data Types: String, Integer, Floating-Point, Exponential, Boolean, NULL

PHP Arrays Contains a set of data represented by a single variable Array names are often referred to with array operators ([ ]) at the end of the name $variable = array(“element1”, “element2”, “element3”); $variable[] = “element1”; Declare an array with $variable = array(values): and access elements within the array by using $variable[index];

PHP Array Example The following “, count($concerts), “ concerts are scheduled: ”; echo “$concerts[0] ”; echo “$concerts[1] ”; echo “$concerts[2] ”; echo “$concerts[3] ”; ?> The following “, count($concerts), “ concerts are scheduled: ”; echo “$concerts[0] ”; echo “$concerts[1] ”; echo “$concerts[2] ”; echo “$concerts[3] ”; ?>

PHP Expressions Expression: a literal value or number Operands: variables and literals contained in an expression Literals: values such as a string or number Operators: symbols such as +, -, *, / that are used in expressions to manipulate operands PHP Operator Types: array, arithmetic, assignment, comparison, logical, special, string

Building PHP Expressions Arithmetic Binary Operators: +, -, *, /, % (modulus) arithmeticbinaryoperators.php Arithmetic Unary Operators: ++ (increment), -- (decrement) arithmeticunaryoperators.php, 100countdown.php, 100countup.php Logical Operators: && (AND), || (OR), ! (NOT) logicalexamples.php

PHP Cash Register cashregister.htmlcashregister.php

Type Casting in PHP Type casting: a way to ensure that a variable is of the correct type $SpeedLimitMiles = “55 mph”; $SpeedLimitKilo = (int) $SpeedLimitMiles * 1.6; echo “$SpeedLimitMiles equals $SpeedLimitKilo.”; To test whether a variable is of a given data type, you should instead use an “is_*()” function is_numeric(), is_string(), is_int(), is_double()

Comparison Operator Example Comparison Operators: Comparison Operators:

Logical Operator Example Logical Operators: Logical Operators:

PHP Do … While Loop Do…While (perform an action while a condition is being met) ”; $num++; } while (($num > 0) && ($num Do…While (perform an action while a condition is being met) ”; $num++; } while (($num > 0) && ($num

PHP If…Else…If Conditional If…Else…If (if this happens, do this, else/otherwise, do this) If…Else…If (if this happens, do this, else/otherwise, do this)

PHP For Loop For (perform this action for a fixed number of times) ”; } ?> ”; } } ?>

PHP Nested For Loop Nesting one for loop inside of another to perform vertical and horizontal actions \n”; for ($y=1; $y \n”; for ($x=1; $x ”; echo ($x * $y); echo “ \n”; } echo “ \n”; } echo “ ”; ?>