Welcome to WebmasterWorld Guest from

Forum Moderators: bill & werty

Message Too Old, No Replies

XML Feed Very Basic Question

Am I Stupid

7:48 pm on Apr 20, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Jan 21, 2003
votes: 0

Hi all

I am new to the XML language but generally get on with most programming etc.....

I have read lots of tutorials the past two days and forums and nothing will get me past the first mental block.

OK here is the question

I have the following example feed that I am trying to display on a standard web page.

I have read lots about XML but I am finding it hard to get a grip on exactly what is needed.

Any pointers as to the html file needed to bring this information into the web page is greatly appreciated.

Also I have hosted web space so the server is limited to what I can place on it.

Ideally I am looking for the following type of response if poss.

1: You need an xml feed
2: You need to parse the XML feed by (uploading something to your website etc etc...)
3: You need to call the uploaded parser in your html etc by this command....

I have read about using a css type xsl to format the XML details in the browser and I understand the concepts behind xml I just cant get to grips with how to actually put it into practice...Ideally I would like to see a non formatted output and then build up upon this by the css attributes that I am learning.

Here is the example feed.

Thankyou for your time any any advice you can give me.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE soccer (View Source for full doctype...)>
- <soccer>
- <cp id="15" nm="ENGLAND: Premier League" dt="2003-11-08">
- <gm id="28386" tm="13:30" c1="Wolves" c2="Birmingham">
<sr ss="FT" r1="1" r2="1" />
<ev pl="Stefan Iversen" tp="goal" mt="66" cb="1" />
<ev pl="Mikael Forssell" tp="goal" mt="49" cb="2" />
- <gm id="28385" tm="16:00" c1="Portsmouth" c2="Leeds United">
<sr ss="FT" r1="6" r2="1" />
<ev pl="Dejan Stefanovic" tp="goal" mt="17" cb="1" />
<ev pl="Gary ONeil" tp="goal" mt="45" cb="1" />
<ev pl="Hayden Foxe" tp="goal" mt="63" cb="1" />
<ev pl="Gary ONeil" tp="goal" mt="71" cb="1" />
<ev pl="Patrick Berger" tp="goal" mt="75" cb="1" />
<ev pl="Aiyegbeni Yakubu" tp="goal" mt="86" cb="1" />
<ev pl="Alan Smith" tp="goal" mt="19" cb="2" />
- <gm id="28384" tm="16:00" c1="Charlton Athletic" c2="Fulham">
<sr ss="FT" r1="3" r2="1" />
<ev pl="Graham Stuart" tp="goal" mt="10" cb="1" />
<ev pl="Jonatan Johansson" tp="goal" mt="69" cb="1" />
<ev pl="Jonatan Johansson" tp="goal" mt="76" cb="1" />
<ev pl="Sean Davis" tp="goal" mt="89" cb="2" />
- <gm id="28383" tm="16:00" c1="Bolton Wanderers" c2="Southampton">
<sr ss="FT" r1="0" r2="0" />
<ev pl="Michael Svensson" tp="rc" mt="86" cb="2" />
- <gm id="28382" tm="16:00" c1="Aston Villa" c2="Middlesbrough">
<sr ss="FT" r1="0" r2="2" />
<ev pl="Boudewijn Zenden" tp="goal" mt="30" cb="2" />
<ev pl="Michael Ricketts" tp="pen" mt="49" cb="2" />
- <gm id="28381" tm="16:00" c1="Arsenal" c2="Tottenham Hotspur">
<sr ss="FT" r1="2" r2="1" />
<ev pl="Robert Pires" tp="goal" mt="69" cb="1" />
<ev pl="Fredrik Ljungberg" tp="goal" mt="79" cb="1" />
<ev pl="Darren Anderton" tp="goal" mt="4" cb="2" />
- <cp id="13" nm="ITALY: Serie A" dt="2003-11-08">
- <gm id="28196" tm="18:00" c1="Sampdoria" c2="Empoli">
<sr ss="FT" r1="2" r2="0" />
<ev pl="Fabio Bazzani" tp="goal" mt="21" cb="1" />
<ev pl="Cristiano Doni" tp="goal" mt="27" cb="1" />
- <gm id="28197" tm="20:30" c1="Brescia" c2="Bologna">
<sr ss="1T" r1="0" r2="0" />
- <cp id="14" nm="SPAIN: Primera Division" dt="2003-11-08">
- <gm id="28405" tm="19:30" c1="Atletic" c2="Espanyol">
<sr ss="2T" r1="1" r2="0" />
<ev pl="Andoni Iraola" tp="goal" mt="15" cb="1" />
- <gm id="28406" tm="19:30" c1="Zaragoza" c2="Celta">
<sr ss="2T" r1="1" r2="1" />
<ev pl="Leonardo Ponzio" tp="goal" mt="7" cb="1" />
<ev pl="Saenz Jose Ignacio" tp="goal" mt="3" cb="2" />
<gm id="28407" tm="21:30" c1="Deportivo" c2="Real Sociedad" />

8:18 pm on Apr 20, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 3, 2003
votes: 0

The piece you are missing deals with a server-side transformation. You forgot to mention if you need a php, asp, .net, or other solution. It seems you're doing good at finding most of the information - if you do a search on "server side transformation" you should find what you need.
9:00 pm on Apr 20, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Jan 21, 2003
votes: 0

Hi John

Thankyou for taking the time to answer my query...

Quick question a little more basic :) ....

I have the XML feed called test.xml

I have a basic blank web page called text.html

What sort of thing will I place in the html code to call the test.xml to display.

Also the parser....is this a physical php type file etc.. that I have to upload to my web server...

All the parsers I have found you install on your pc which is no use to me as I want this to run on my shared web server page.

9:12 pm on Apr 20, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 3, 2003
votes: 0

I have only done it via ASP, but in a general form:

You need something that can perform the HTTP request to fetch the xml file. And yes, this would be another program or script. Optimally, this would be done with some type of cacheing, but that will depend upon the script/program you use. (The cacheing is good for the provider and it makes your site's response time faster)

Then you will need another script or program to load the XSL file and perform the transformation. This may be part of the same one that fetches the XML, or it may be a separate piece.

Depending upon the XSL, the transformation may return a full HTML document, or it may simply return a content block that you then use within your PHP.

You could also do a "manual" transformation in PHP. To do this, look for something that will let you work with XML documents and XPaths.

There are also solutions available that let you simply put a piece of javascript into your page. The javascript will invoke someone else's transformation service and put the html into your page on the fly. Obviously you are dependent on the 3rd party transformation service. You also have less control over things. I think you can find a few of these that are free by searching for "consuming an RSS feed" or something along those lines.

9:15 pm on Apr 20, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 3, 2003
votes: 0

I forgot to mention regarding the solution which utilizes javascript and a 3rd party transformation service: The transformation would take place on the client - so the browser must be XML/XSL aware. Definitely a downside.
12:26 pm on Apr 23, 2004 (gmt 0)

Full Member

10+ Year Member

joined:May 27, 2003
votes: 2

The simplest way is to use an XSL transform.
XSL is the prefered way of manipulating XML.. that's what's its designed for.

There are two ways I know to get the transform done.

1. Through browsers like IE6 that can do this on the fly.
Name the following code simpleOutput.xsl
and on top of your xml add a link to the stylesheet. ie..
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simpleOutput.xsl"?>
then send the xml to the browser and the transform will be performed.

2. Or getting yourself a XSLT processor the like of Saxon, from saxon.sourceforge.net which will generate an output file output.html which you can upload.

3? The third way which I imagine is possible would be to get the server to generate new processing of the transform each time the xml updates, generating a new html file; but I don't know how to do this.


<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<h1><xsl:value-of select="./soccer/cp/@nm"/><xsl:text> </xsl:text><xsl:value-of select="./soccer/cp/@dt"/></h1>
<p>Table of results</p>
<table border="1">
<tr bgcolor="#9acd32">
<th>Scores at</th>
<th>Home team</th>
<th>Away team</th>
<xsl:for-each select="./soccer/cp/gm">
<xsl:sort select="./@tm"/>
<td><xsl:value-of select="./@id"/></td>
<td><xsl:value-of select="sr/@ss"/></td>
<td><xsl:value-of select="./@c1"/></td>
<td><xsl:value-of select="sr/@r1"/></td>
<td><xsl:value-of select="./@c2"/></td>
<td><xsl:value-of select="sr/@r2"/></td>
<xsl:for-each select="./ev">
<td><xsl:text> </xsl:text></td>
<td><xsl:value-of select="./@pl"/></td>
<td><xsl:text>scored </xsl:text><xsl:value-of select="./@mt"/><xsl:text> min</xsl:text></td>