Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xml and download links

Status
Not open for further replies.

mjohnson24

Technical User
May 19, 2009
6
US
Hi i have a file called index.html that is set up to pull data from an external xml file. It lists multiple different sermons for my church that i want to be able to have a person click on one of the titles and it will download the audio file for them. Below is what i have so far in the xml file and the index.html file. But If i add the link= tag in the title of the xml file then it makes the titles disappear when i view it in the browser but if i keep the link= out then the columns display correctly. Any Ideas? I also want another link that they can click on that will allow them to just play it through the browser if possible. So one button for downloading the file and one to jsut play in browser.

HTMl File:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<xml id="myExternalData" src="items.xml"/>
<table datasrc='#myExternalData' border="1">
<thead>
<tr>
<th>
Message Title</th>
<th>
Artist</th>
<th>
Sermon Date</th>
<th>
Message Length</th>
<th>
Download</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span datafld='title' />
</td>
<td>
<span datafld='artist' />
</td>
<td>
<span datafld='date' />
</td>
<td>
<span datafld='length' />
</td>
<td>
<span datafld='links' />
</td>
</tr>
</tbody>
</table>
</body>
</html>


XML File:
<?xml version="1.0"?>

<items>
<item id="item1">
<title>Nothings too Hard for God</title>
<artist>Scott Holmes</artist>
<date>9/6/2009</date>
<length>1:07:02</length>
</item>
<item id="item2">
<title>Nothings too Hard for God 2</title>
<artist>Justin Grace</artist>
<date>9/13/2009</date>
<length>30:12</length>
</item>
<item id="item3">
<title>Nothings too Hard for God 3</title>
<artist>Joben Murray</artist>
<date>9/20/2009</date>
<length>55:48</length>
</item>
<item id="item4">
<title link=" too Hard for God 4.m4a">Nothings too Hard for God 4</title>
<artist>Scott Holmes</artist>
<date>9/27/2009</date>
<length>42:47</length>
</item>
</items>
 
[0] The link value as shown is not really valid url, though I understand it is as a kind of showing the idea, but still...

[1] I would say it would be dubious to fight tabular data for the kind of data island more useful for flat data without hierachy. In particular, for a small application.

[1.1] It can be done with extra works to reflect the hierchical structure. It can be done like this.
[tt]
<body>
<xml id="myExternalData" src="items.xml"/>
<table datasrc='#myExternalData' border="1">
<thead>
<tr>
<th>
Message Title</th>
<th>
Artist</th>
<th>
Sermon Date</th>
<th>
Message Length</th>
<th>
Download</th>
</tr>
</thead>
<tbody>
<tr>
<td>
[red]<table datasrc="#myExternalData" datafld='title'><tr><td><span datafld='$TEXT'> </span></td></tr></table>[/red]
</td>
<td>
<span datafld='artist' />
</td>
<td>
<span datafld='date' />
</td>
<td>
<span datafld='length' />
</td>
<td>
[red]<table datasrc="#myExternalData" datafld='title'><tr><td><a datafld="link" target="_blank"><span datafld="link"> </span></a></td></tr></table>[/red]
</td>
</tr>
</tbody>
</table>
</body>
[/tt]
[3] If the xml is under your control, make the link an element under item, sibling to title etc... That would make the tabular data use of xml data island simpler. Why make it more complicated, one may ask. (There isn't huge ambition in the use of xml data island to begin with.)
 
note:
Due to the formatting of the forum, the place where you've seen a space between [tt]<span ...>[highlight] [/highlight]</span>[/tt], I had actually put an [blue][ignore]&_n_b_s_p_; [/ignore][/blue] (without underscore "_") there.
 
Thanks for your help so far but unfortunately i dont know much at all about xml language so i copied what you have above but im missing something cause it dont seem to work correctly.
 
well i copied the html stuff you had above into another html file and then edited the xml file as below and it didnt seem to pull the data from the xml file at all. the fields were blank when viewing it. not sure if this is the easiest way to do it or not but i just thought i could use xml to control the audio list better than jsut adding it all in one html file plus the html file wont be miles long to search for stuff and then have to edit or delete table cells when i want to change stuff around. XML files are just easier to deal with. Any suggestions you have that may be better feel free to let me know.


<?xml version="1.0"?>

<items>
<item id="item1">
<title>Nothings too Hard for God</title>
<artist>Scott Holmes</artist>
<date>9/6/2009</date>
<length>1:07:02</length>
<link> vs Machine.m4a</link>
</item>
<item id="item2">
<title>Nothings too Hard for God 2</title>
<artist>Justin Grace</artist>
<date>9/13/2009</date>
<length>30:12</length>
<link> vs Machine.m4a</link>
</item>
<item id="item3">
<title>Nothings too Hard for God 3</title>
<artist>Joben Murray</artist>
<date>9/20/2009</date>
<length>55:48</length>
<link> vs Machine.m4a</link>
</item>
<item id="item4">
<title>Nothings too Hard for God 4</title>
<artist>Scott Holmes</artist>
<date>9/27/2009</date>
<length>42:47</length>
<link> vs Machine.m4a</link>
</item>
</items>
 
Why do you change the xml structure? I answer your original question.
 
I changed it cause i thought you said put link as en element under items. i dont know anything about xml. im learning xml or trying to right now. i keep my xml document like the priginal way and copied your html structure and it didnt pull the data so i changed the xml structure to the way above and it still didnt work. what am i doing wrong? as bad as i hate to say it its gonna take someone to walk me through it step by step so i can understand it all and see how its working before i can get it.
 
Just use the original xml with my posted answer (body part of the html, the rest unchanged.)

I did suggest a flat structure in [3]. But that would go with your original html no problem, only with less functionality like download or watch from the url.

"Original" means your first post, if that is not the right word so that you understand.
 
It did work. I guess the IE browser on my work computer which is version 8 the same as the one here at home doesnt work for some reason. But it did here at home. One thing though, is there a way to do it so that it only shows the word "Download" and all so that the link isn't shown on the page? Just for a cleaner look.
 
But that is only for IE, to begin with and all along.

If you want to use the flat xml structure as [3] and use the simpler html in your original post, learn how I construct the link anchor tag (<a></a>) in my answer and use the same method to improve the td part for the download column.
 
Ok i have the html and xml data above posted at and the xml file can be looked at at It all works great but just one simple question, how do i get it so that i can have an image shown or even just text displaying the word download or play or an image or something like that instead of the whole link like shown. But it only works in IE as i think one of your posts mentioned. How do i get it to work in firefox and safari? Or is there a different way i need to do it to get it to show in other browsers other than IE? If so where can i find a sample of it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top