|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
adding xml links to html web page
I know this might be easy for everyone. Im having a hard time finding a simple example of this.
All i want to do is have an xml file of links and then show them in my main html web page, and make them clickable... anyone have a simple example?? |
|
#2
|
||||
|
||||
|
Show an example of your XML file.
Are you using HTML or XHTML?
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
HTML, but i can change to XHTML if thats easier.
|
|
#4
|
|||
|
|||
|
I dont even have an example of the xml..
Im assuming it'd be something like this.. <archive> <link name="10/10/2001" href="archive/101001.html" /> </archive> |
|
#5
|
||||
|
||||
|
If you want a specific answer you'll need to provide a specific XML example for us to work with. Let me know so I'm not wasting time.
|
|
#6
|
|||
|
|||
|
ok,
then the xml would look like this <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="xmltest2.xsl"?> <link> <text>Google</text> <url>http://www.google.com</url> </link> |
|
#7
|
|||
|
|||
|
Jeremy, thanks, but i was finally able to find an example of this on the net after searching all day....
for anyone that is interested in a working example of this.. here they are.. THE XML: (save as linktest.xml) <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="linktest.xsl"?> <CODEHELP> <!--Test file from www.codehelp.co.uk--> <NAVIGATE> <FILE>../xml/anyfile.xml</FILE> <DESC>Change the FILE entry to point to a real file</DESC> <CLICK>A test link only</CLICK> </NAVIGATE> <NAVIGATE> <FILE>../xml/anyfile2.html</FILE> <DESC>Add more navigate/file/desc/click tags for more links</DESC> <CLICK>Adding more links</CLICK> </NAVIGATE> </CODEHELP> THE XSL (save as linktest.xsl) <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <HEAD> <link rel="stylesheet" href="../css/content.css" type="text/css"/> <title>Test</title> </HEAD> <BODY> <div style="position:absolute;top:20%;left:20%;"> <h1>These links are not all active.</h1> <h3>Hover over each link to get more information.</h3> <ul style="line-height:1.7;"> <li><a href="anyfile.xml" title="This could be your home page - added to all XML's">Your home page?</a></li> <xsl:apply-templates select="CODEHELP/NAVIGATE" /> <h4>These next links are active</h4> <li><a href="../links/index.html" title="Link to html, xml, shtml, use relative as well as absolute links">Links</a></li> <li>Return to the <a href="../index.html" title="Home page">CodeHelp home page</a> here.</li> <li>Go back to the <a href="seventh.xml" title="test files page">previous file</a> here.</li> </ul> </div> </BODY> </html> </xsl:template> <xsl:template match="CODEHELP/NAVIGATE"> <li> <a> <xsl:attribute name="href"> <xsl:value-of select="FILE"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="DESC"/> </xsl:attribute> <xsl:value-of select="CLICK"/> </a> </li> </xsl:template> </xsl:stylesheet> put them in the same directory on a hosted server and just run the linktest.xml the links dont actually go anywhere but the syntax works. |
|
#8
|
||||
|
||||
|
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:for-each select="link">
<p><a href="{url}"><xsl:value-of select="text" /></a></p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
#9
|
|||
|
|||
|
Yours is alot easier...thanks
|
|
#10
|
|||
|
|||
|
External XML Files
What about External XML Files where you cannot specify the the style sheet in the XML File?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > adding xml links to html web page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|