Download presentation
Presentation is loading. Please wait.
Published byJob Strickland Modified over 9 years ago
1
Date : 3/3/2010 Web Technology Solutions Class: Application Syndication: Parse and Publish RSS & XML Data
2
Tonight ✤ Introduction to XML ✤ Creating XML, RSS, and JSON with PHP ✤ using simpleXML for XML\RSSLab
3
Lab Preview ✤ Application Development ✤ Registration Feature ✤ Login\Logout ✤ Maintain State ✤ Admin CRUD for Survey ✤ Publish XML and RSS
4
Lab Preview ✤ Application Development: ✤ Adding XML and RSS ✤ Publish an RSS feed of your survey responses ✤ Publish an XML dump of your survey responses ✤ You will implement an ECO to provide XML publication of a table in your database. Provide a URL of feed.
5
Final Project Review ✤ Final Project - Web App (link) ✤ registration feature (week 6) ✤ login logout (week 7) ✤ admin ability to create\read\update\delete (CRUD) (week 4-5) ✤ Maintain State throughout app (cookies\sessions) (week 7) ✤ XML and RSS feeds (week 8) ✤ Valid XHTML and CSS design
6
Web Apps ✤ Problem with apps: ✤ Data stored in other systems can’t be shared easily. ✤ Data is in different formats ✤ Data has no meaning to other systems, just its own native system.
7
Web Apps ✤ Goals: ✤ Share information across multiple environments ✤ Open, flexible language to share data ✤ Provide schematic meaning to data elements
8
Solution:XML
9
Intro to XML ✤ Markup language for documents containing structured information. ✤ Extensible Markup Language (akin to HTML) ✤ Supported by W3C as a standard ✤ Provides known structure and relevant meaning to that data structure. ✤ Widely used (iTunes, e.g.) ✤ Perfect for PHP developers to share data.
10
Terms of XML ✤ Meta: literally “provides meaning”. ✤ Schema: A logical organized structure of data. ✤ Tags: Elements in XML that are data containers ✤ Attributes: Extend meaning of a tag ✤ Serialize: saving or storing data ✤ Nodes: a DOM structure of a data object (tree)
11
XML Sample ✤ Consider this example: ✤ ✤ Smithson ✤ Apex DVD Player 1.2 ✤ 3 ✤ 33cm ✤ black ✤
12
XML Syntax Structure ✤ Consider this example: ✤ // XML Definition (version) ✤ ✤ Smithson ✤ Apex DVD Player 1.2 ✤ 3 ✤ 33cm ✤ black ✤
13
XML Syntax Structure ✤ Consider this example: ✤ // XML Definition (version) ✤ // Extending Tagging System (user defined markup adds meaning) ✤ Smithson ✤ Apex DVD Player 1.2 ✤ 3 ✤ 33cm ✤ black ✤
14
XML Syntax Structure ✤ Consider this example: ✤ // XML Definition (version) ✤ // Extending Tagging System (user defined markup adds meaning) ✤ Smithson //Tags are created and defined by the developer (XSD) XML Schema ✤ Apex DVD Player 1.2 ✤ 3 ✤ 33cm ✤ black ✤
15
XML Syntax Structure ✤ Consider this example: ✤ // XML Definition (version) ✤ // Extending Tagging System (user defined markup adds meaning) ✤ Smithson //Tags are created and defined by the developer (XSD) XML Schema ✤ Apex DVD Player 1.2 //Tags contain strictly strings ✤ 3 //requires: start tag and end tag ✤ 33cm // string value is found between the tags. ✤ black //tags can have attributes ✤
16
Nodes in XML ✤ The Node: ✤ Contains all relevant data about an element. ✤ For example:, which contains all the data for that individual product. ✤ This node has “childnodes”, such as ✤ Data can be a string (but more...)
17
CDATA in XML ✤ CDATA ✤ Data can hold more complex data, like HTML, using CDATA. ✤ Tells the node to contain “raw character data”, not markup. ✤ <![CDATA[ ✤ ]]> ✤ Good for containing html, JS, etc, as it will not be treated as plain string data.
18
Create XML with PHP ✤ fopen() - allows you to open a document on the filesystem. // resource ✤ you can $file= fopen("presidents.xml", "w"); // note safe_mode, open_basedir ✤ read only (r) ✤ read and write(r+) ✤ write only(w) ✤ write and create(w+) ✤ write to end of file (a) ✤ write to end and create (a+) ✤ permissions are an issue! Try chmod to 777 to start and throttle back.
19
Create XML with PHP ✤ fwrite() ✤ Write to the resource you were using. ✤ Allows you to complete the write to the file system ✤ will return the bytes written if successful. ✤ Be aware of permissions! chmod 777 to start and go lower as needed.
20
Create XML with PHP ✤ fclose() ✤ closes the current resource. ✤ returns boolean. worth checking!
21
XML Example
22
Create RSS with PHP ✤ Stands for “Real Simple Syndication” ✤ great for sharing or syndicating your content to outside systems ✤ commonly only holds “some recent data” ✤ natively uses XML as a transport ✤ Has several standardized formats. ✤ We’ll use RSS 2.0, common usage.
23
Create RSS with PHP ✤ RSS has a defined format: ✤ A Channel which allows to add meta about what your syndicating ✤ Should Contain a title, link, and description, (optional date, language,etc) ✤ RSS should have a defined tabbed structure ✤ Related Links: often found on blogs to send a person to the correct page to get more details.
24
Create RSS with PHP ✤ Browsers “sniff” for RSS feeds on a site ✤ You let the browser know you’re publishing RSS by embedding a meta data tag: ✤
25
RSS Example
26
SimpleXML ✤ Simple XML is PHP5’s long- awaited class that allows PHP developers to easily and effectively parse XML data! ✤ Simple to Use (its in the name) ✤ Lets see it in action.
27
xPath ✤ What is xPath and why do I care? ✤ XSLT Standard by the W3C ✤ xPath is a syntax for finding information in XML documents ✤ Can find values in nodes or attributes ✤ xPath is part of SimpleXML ✤ Learn more about it! Learn more about it!
28
Lab & Next Week ✤ Lab ✤ implement xml\rss in app ✤ working session for final ✤ Reading: Chapter 13 See you Sunday!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.