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 April 24th, 2004, 01:01 PM
garretthethief garretthethief is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 garretthethief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Referencing Data: Simple Newbie Question

I'm trying to do something that I would think would be fairly straightforward-- reference urls stored in a xml file. The xml file is of the following format (using google for example):

<item>
<name>Google</name>
<link>http://www.google.com</link>
</item>

So how would I reference this in HTML so that it outputs a list of names that take you to the links? Is this even possible? Just curious

Reply With Quote
  #2  
Old April 25th, 2004, 05:39 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 305 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 7 h 17 m 54 sec
Reputation Power: 7
Here is a short example of one way of doing it.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="/">
   <xsl:apply-templates select="item"/> 
</xsl:template>

<xsl:template match="item" >
   <xsl:element name="a">
      <xsl:attribute name="href">
         <xsl:value-of select= "./link" />
      </xsl:attribute>
      <xsl:value-of select="./name" />
   </xsl:element>
</xsl:template>

</xsl:stylesheet>

Reply With Quote
  #3  
Old April 25th, 2004, 11:39 PM
garretthethief garretthethief is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 garretthethief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wow! Thanks alot. It works great.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Referencing Data: Simple Newbie Question


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 2 hosted by Hostway
Stay green...Green IT