XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 26th, 2004, 03:06 PM
mwilson mwilson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 6 mwilson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Populating <img> and <a> tags with XML?

My question: I'm using a HTML page to call an XML file (I know - I should use XSL... but I can't because I my file has to be a .html file... don't ask) and the only thing I can't get to work are the <img> and <a> tags.

I'm using <div datafld="xxx" /> for other fields and that's working fine - but I'm stuck on getting the <img src> to display the image and the <a> tag getting the URL from my xml file to the href (or similiar) attribute.

Thanks in advance-
Matt

html code:
<xml id="xmldso" src="file.xml"></xml>
<table datasrc="#xmldso">
<tr>
<td>
<img datafld="imagepath">
<a datafld="URL" href="" />
</td>
</tr>
</table>

xml example:
<deal>
<title>xxx</title>
<company>yyy</company>
<imagepath>images/devshedlogo.jpg</imagepath>
<URL>http://www.devshed.com</URL>
</deal>

Reply With Quote
  #2  
Old February 27th, 2004, 03:52 PM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
I didn't know that you could obtain information from an XML document using strictly HTML. This seems wrong. Has anyone else ever seen this or know if something like this will work?

The only solution like this I know of is using JavaScript to read in the XML document and then using it to parse, read and then set values in the HTML.

Reply With Quote
  #3  
Old February 27th, 2004, 04:19 PM
majelbstoat's Avatar
majelbstoat majelbstoat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Manchester, England
Posts: 39 majelbstoat User rank is Sergeant (500 - 2000 Reputation Level)majelbstoat User rank is Sergeant (500 - 2000 Reputation Level)majelbstoat User rank is Sergeant (500 - 2000 Reputation Level)majelbstoat User rank is Sergeant (500 - 2000 Reputation Level)majelbstoat User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 h 4 m 46 sec
Reputation Power: 11
It's a Microsoft only "standard" :-) Apparently the <xml> tag only works in IE 5.0 and above, and isn't part of any standardised specification. It's an html tag, not an xml tag.

W3Schools gives this short demo which I managed to get working:

<html>
<body>

<xml id="cdcat" src="cd_catalog.xml"></xml>

<table border="1" datasrc="#cdcat">
<tr>
<td><span datafld="ARTIST"></span></td>
<td><span datafld="TITLE"></span></td>
</tr>
</table>

</body>
</html>


mwilson, i've used something similar:

<xml src="photoalbum.xml" id="xmldso" async="false"></xml>

...

<p>
Title:
<span datasrc="#xmldso" datafld="TITLE"></span>
</p>

<p>
Description<br />
<span datasrc="#xmldso" datafld="DESCRIPTION"></span>
</p>

<a datasrc="#xmldso" datafld="IMAGE" target="_blank">
<img alt="Click For Large Version" datasrc="#xmldso" datafld="THUMBNAIL" border="0"></img>
</a>


maybe you could try

<img alt="My Picture" datasrc="#xmldso" datafld="imagepath" border="0"></img>

instead of having the datasrc in the table tag?

Hope this helps, - I'm new to all this as well :-)

Jamie.
__________________
Practise Random Kindness

Reply With Quote
  #4  
Old March 1st, 2004, 09:08 AM
mwilson mwilson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 6 mwilson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by MattSidesinger
I didn't know that you could obtain information from an XML document using strictly HTML. This seems wrong. Has anyone else ever seen this or know if something like this will work?

The only solution like this I know of is using JavaScript to read in the XML document and then using it to parse, read and then set values in the HTML.


Thanks Matt... do you have a JS func for the solution you mentioned? I'd hate to just use the <xml> tag and alienate all our non-IE users.

Thanks again all-

Reply With Quote
  #5  
Old March 1st, 2004, 09:13 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 5
Send a message via AIM to MattSidesinger
I believe that even the JavaScript solution would be for IE users only because you would have to create a Microsoft.XMLDOM ActiveX object.

I believe that Mozilla based browsers may be able to do the same thing (not with ActiveX, but read in an XML document with a plug-in perhaps), but I am unsure on how to do this and you would have to start incorporating brower sniffing which I am against.

I hope that someone else can help you.

Matt

Reply With Quote
  #6  
Old March 18th, 2004, 03:30 AM
latrosicarius latrosicarius is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 75 latrosicarius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 1 m 11 sec
Reputation Power: 5
Send a message via AIM to latrosicarius
Don't worry, you CAN use XSL!

Matt, about this:
Quote:

I'm using a HTML page to call an XML file (I know - I should use XSL... but I can't because I my file has to be a .html file... don't ask)


It is common for free web service providers like GeoCities to restrict the naming of files (that have certian HTML tags) alowed on their servers to .html or .htm extensions. However, there is good news (hopefully in your case). You do not need to name your .xsl stylesheet with a .xls extension. You can use .txt as long as it is still internally identified a xsl stylesheet doctype with the usual W3C standard declaration tags that are placed at the top of the file.

Example of what to have at the top of your .txt XSL stylesheet named "home_stylesheet.txt" in a subdirectory (relative to the location of your XML file) that I named "resources":
Code:
 
<?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="/">
  <?xml version="1.0"?>
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>  
	<title>
	</title>
	<link rel="stylesheet" type="text/css" href="resources/global_stylesheet.css" />
   </head>
   <body>
...


Example of what to have at the top of your .xml XML file (named "home.xml"):
Code:
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="resources/home_stylesheet.txt"?>
<root>
 <general>
  <title>
   Home
  </title>
 </general>
</root>


Sorry this is a few days late -- I just signed up here today. I really hope you can use this to format your XML data through a XLS stylesheet like you probably would like, instead of a regular HTML document. Also, you should upgrade your HTMLs to XHTMLs if you want to use either XLS or XML. If you don't know how XHTML differs from HTML, you can always go to the W3Schools XHTML tutorial page or download this Windows GUI version of Dave Raggett's HTML Tidy program from W3C, which parses your the HTML and, based on your preferences, will convert it to XHTML.

Good luck!
Latrosicarius

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Populating <img> and <a> tags with XML?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT