|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Hello everyone
I am new to php and stuck somewhere in php+xml. I have an .xml file where inside "title" tag there is website's "title", below inside "keyword" tags there are "meta keywords" of the website. I want to fetch the different data from that xml file and show it in proper place. How to do this?? any idea? But there shouldnt be two different xml file....all the datas will be stored inside that xml file only. Here is my .xml example:: <?xml version="1.0" encoding="iso-8859-1"?> <phrase> <title>Title goes here</title> <keyword>mykeyword one</keyword> <keyword>mykeyword two</keyword> <keyword>mykeyword three</keyword> </phrase> Please help me.. Regards-
__________________
Developersouvik [Technology & creativity Spun together] http://developersouvik.orgfree.com |
|
|||
|
If you're new to this like I am you will find this xslt stylesheet quite revealing. It was a lot of fun to create:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "*">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xsl:variable name="header">
<tr bgcolor="#cccccc">
<th style="text-align:left;width:10%">ID</th>
<th style="text-align:left;width:60%">Course Name</th>
<th style="text-align:left;width:30%">Instructor Name</th>
</tr>
</xsl:variable>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table style="width:100%;border-collapse:collapse;border:none;font:normal 0.7em 'Trebuchet MS',Arial,sans-serif">
<xsl:copy-of select="$header" />
<xsl:for-each select="document/row">
<tr>
<td><xsl:value-of select="id"/></td>
<td>
<a>
<xsl:attribute name="href" >
index.php?id=<xsl:value-of select="courseid"/>
</xsl:attribute>
<xsl:attribute name="target" >
_top
</xsl:attribute>
<xsl:value-of select="coursename"/>
</a>
</td>
<td>
<a>
<xsl:attribute name="href" >
/instructors/index.php?id=<xsl:value-of select="instructorid"/>
</xsl:attribute>
<xsl:attribute name="target" >
_top
</xsl:attribute>
<xsl:value-of select="instructorname"/>
</a>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
If you get an answer to your question it's hoped I may get an answer to mine. I've included this example to illustrate the relationship between the data set and the style sheet template. Like many of my projects, this is a scratch on the surface but it works, for now, until a php solution can be found. Here is a segment of the xml. Note the stylesheet element... Code:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="courses.xsl" ?> <document> <row> <id>1</id> <courseid>stress_perception</courseid> <coursename>All Stressed Up and No Place to Go</coursename> <instructorid>deb_milne</instructorid> <instructorname>Deb Milne</instructorname> <objective>1</objective> <flag>1</flag> </row> <row> <id>2</id> <courseid>asist</courseid> <coursename>Applied Suicide Intervention Skills Training</coursename> <instructorid>csp_asist</instructorid> <instructorname>Center for Suicide Prevention</instructorname> <objective>1</objective> <flag>1</flag> </row> <row> <id>3</id> <courseid>first_aid_training</courseid> <coursename>St. John Ambulance First Aid</coursename> <instructorid>st_john_ambulance</instructorid> <instructorname>St. John Ambulance Training</instructorname> <objective>1</objective> <flag>1</flag> </row> <row> <id>4</id> <courseid>cpr-aed</courseid> <coursename>St. John Ambulance CPR-AED</coursename> <instructorid>st_john_ambulance</instructorid> <instructorname>St. John Ambulance Training</instructorname> <objective>1</objective> <flag>1</flag> </row> <row> <id>5</id> <courseid>food_safety</courseid> <coursename>Food Safety</coursename> <instructorid>thor_hameister</instructorid> <instructorname>Thor Hameister</instructorname> <objective>1</objective> <flag>1</flag> </row> </document> Code:
<table id="coursetable" summary="" class="layout pagecore">
<tr><td class="leftbar"> </td>
<td class="contentbox">
<div class="shell" style="margin-bottom:1em">
<h2><a href="index.xml" title="full Course and Instructor table">Table of Courses and Instructors</a></h2>
<iframe src="courses.xml" name="cwtable" width="100%" style="border:none">
If you can see this, your browser doesn’t understand IFRAME. View the
<a href="index.xml" target="_blank"> full Course and Instructor table</a> in a new window.
</iframe>
</div>
</td>
</tr>
</table>
Last edited by weegillis; 11-26-2008 at 01:23 AM. Reason: Adding omitted html code |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do i separate adwords data in Google Analytics from organic data | inertia | Google Discussion Forum | 8 | 08-20-2008 12:10 PM |
| Post Impression data for Keyword Search/CPC data? | phunklord | Marketing Strategies Discussion Forum | 2 | 07-21-2005 08:16 AM |
| Google Showing Different data at different data centers | Yatin | Google Discussion Forum | 1 | 02-25-2005 08:01 AM |
| Free Data Merchant Data Cleaner - Beta Release | Chris - WSO | Affiliate Marketing Discussion Forum | 2 | 12-27-2004 10:19 PM |
| Using MLS data | oneeye | Graphics & Design Discussion Forum | 10 | 06-04-2004 09:15 PM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |