|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Creating a Hyperlink in HTML from xml data...
Hello I am an XML newbie, and I have created my first page genrated from xml data using an xsl style sheet.. If I am saying that correctly.
I wish to use the following xml and xsl sytlesheet and have the ip data appear as a hyperlink in the final page with the ip adress and a refrence that is that same data... any help would be greatly appreciated. Here is My xml <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Authour: Robert Marchionne --> <?xml-stylesheet type="text/xsl" href="index.xsl" ?> <Machine_Listing xmlns:xlink="http://www.w3.org/1999/xlink"> <machine> <ID>Jayson Barker</ID> <class>desktop</class> <model>2645</model> <type> V4U</type> <serial>$5.95</serial> <ip>9.51.62.133</ip> <!-- I want this to appear on my page as a hyperlink to this ip address --> </machine> <machine>..... ...</machine> </Machine_Listing> Here is my xsl file... <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited with XML Spy v4.2 --> <HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#EEEEEE"> <xsl:for-each select="Machine_Listing/machine"> <DIV STYLE="background-color:red; color:white; padding:4px"> <SPAN STYLE="font-weight:bold; color:white"><xsl:value-of select="ID"/></SPAN> - <xsl:value-of select="class"/> </DIV> <xsl:value-of select="ID"/> <DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt"> <SPAN STYLE="font-style:italic"> (<xsl:value-of select="type"/> model) <xsl:value-of select="ip"/> </SPAN> </DIV> </xsl:for-each> </BODY> </HTML> |
|
#2
|
|||
|
|||
|
Instead of saying this:
Code:
<ip>9.51.62.133</ip> Say this: Code:
<ip>&l_t;a href="http://9.51.62.133/"&g_t;9.51.62.133&l_t;a&g_t;</ip> except where i have an underscore (_) character in the &l_t; and &g_t; things, take out the underscore. The reason is is that a &l_t; thing means a LESS-THAN sign ( < ) and a &g_t; thing means a GREATER-THAN sign ( > ), but you can't just write them in the XML b/c then the XML will think they are XML nodes. Unfortunatly, XML does not have a CDATA equivelant for HTML content, so you have to use replacement characters for HTML symbols such as: &l_t; for < &g_t; for > &a_mp; for & &q_uot; for " etc. (ALL WITHOUT THE UNDERSCORE CHARACTER) Hope this helps, Matt G. |
|
#3
|
||||
|
||||
|
Quote:
PHP Code:
I had to adjust your xsl to make this work, so here is the entire stylesheet: PHP Code:
|
|
#4
|
|||
|
|||
|
That is exactly what i was looking for.. Ty very much
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Creating a Hyperlink in HTML from xml data... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|