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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing links in XML.

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
I have a simple XML file that contains news about our site. I want to be able to put links into the XML so that when shown with an XSLT they appear as links. How can I do this?

ex. I want <a href=&quot;mailto:someone@somewhere.com&quot;>Dude</a> to appear as Dude
 
use xsl:element to build ur anchor element then put ur text from ur XML in the element

<xsl:element name=&quot;a&quot;>
<xsl:attribute name=&quot;href&quot;>
<xsl:value-of select=&quot;.&quot;/>
</xsl:attribute>
<xsl:value-of select=&quot;text()&quot;/>
</xsl:element>

That's not exact code but u should get the idea

-pete
 
Not sure that's what I'm looking for. I have a paragraph I am storing, and in it is the link. So what I have looks like this:

Customers must now log-in to access the online forms. We have updated them to work With our database and therefore we can provide enhanced features. To get your studio set up to use these forms please <a href=&quot;mailto:someone@somewhere.com&quot;>Contact Us</a> at <a href=&quot;mailto:someone@somewhere.com&quot;>someone@somewhere.com</a>. Or you can call us at (860) 289-9501.

And I want the links to appear as links, not HTML code.
 
>> I have a paragraph I am storing, and in it is the link
>> I have a simple XML file that contains...

[ponder]
no idea what ur asking

-pete
 
I don't have your answer qwert, but if you don't mind I'm going to rephrase your question for those that do know, cause I'm curious too...

palbano

Imagine this...

<note>
<to>You</to>
<from>Me</me>
<msg>Here is a bunch of useless text<a href=&quot;mailto:blah@blah.com>Contact us!</a> Have a good day</msg>
<signoff>Sincerely</signoff>
</note>

XML is going to go goofy with the <a href...

Oh, now I know the answer...

you need a CDATA section!

-Rob

 
Okay, this paragraph:

Customers must now log-in to access the online forms. We have updated them to work With our database and therefore we can provide enhanced features. To get your studio set up to use these forms please <a href=&quot;mailto:someone@somewhere.com&quot;>Contact Us</a> at <a href=&quot;mailto:someone@somewhere.com&quot;>someone@somewhere.com</a>. Or you can call us at (860) 289-9501.

Needs to be stored in xml, and when viewed look like this:
Customers must now log-in to access the online forms. We have updated them to work With our database and therefore we can provide enhanced features. To get your studio set up to use these forms please Contact Us at someone@somewhere.com. Or you can call us at (860) 289-9501.

This is so that when people view this xml page, they don't see the code in the first paragraph (which is messy) but can click the links in the paragraph.
 
>> XML is going to go goofy with the <a href...

Well actually if u fix ur two typo's xml has no problem with it. But i don't consider that a &quot;a simple XML file&quot;!

having html fragments stored in XML like that is NOTsimple.

Anyway depending on what version of XSL(T) ur using i think you can do simple substring() type select statements, so u might be able to parse off &quot;mailto:&quot; and get at the address by referencing the href attribute something like this:

<xsl:value-of select=&quot;@href[substring(7)]&quot;/>

but perhaps not.. in which case u need real XML like:

<link type=&quot;mailto&quot;>
<addr>xyz@hotmail.com</addr>
<display>Support</display>
</link>

Then you have something you can work with.

-pete
 
Ok, well... why not just use a CDATA block though? I'm assuming the purpose of this is to redisplay it later, so if you use the CDATA block, it'll just be preserved as is and rewritten as is... in fact I thought exactly this type of thing is what you'd want... if for example you were submitting news to a news agency and they gave you the format you may not have the option of redefining links within the body of your text as such.

I dunno, looks to be an example of exactly what CDATA was defined for to me, but I'm new to this so if I'm missing something please do let me know.

-Rob
 
When I mean simple, I only want 2 columns of data, one for the Date, one for the News to be posted for that date. The second column should be able to take text added thru a web form, and then present it in the style I have laid out in the xsl file.

palbano, what two typos do you mean in 'ur' statement?

I want to keep this very simple so that I can just dump the date and paragraph into it. Not every record will have html in it.
 
Okay, here is what my xml looks like (1 record):
<ITEM>
<DATE>February 4th, 2002</DATE>
<BODY>Customers must now log-in to access the online forms. We have updated them to work With our database and therefore we can provide enhanced features. To get your studio set up to use these forms please <![CDATA[<a href=&quot;mailto:so@someone.com&quot;>Contact Us</a> at <a href=&quot;mailto:so@someone.com&quot;></a>so@someone.com</a>]]>. Or you can call us at (555) 555-5555.</BODY>
</ITEM>

I can still see <a href...></a> when I browse to the .xml page. But at least my xsl is working... I don't want to see html code, I want to see hyperlinks...
 
>> palbano, what two typos do you mean in 'ur' statement?

from skiflyer:

<note>
<to>You</to>
<from>Me</me>
<msg>Here is a bunch of useless text<a href=&quot;mailto:blah@blah.com&quot;>Contact us!</a> Have a good day</msg>
<signoff>Sincerely</signoff>
</note>

 
Forget it, I can't find help that makes any sense, I'm going back to a database where I can make the text I want be what the browser sees. It'll be real simple. And something I can understand. I don't want to create fields called signoff or from or any of that junk. I simply want a string to be sent to the browser that the browser can see as a link and display it as such. I don't see how that is such a hard thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top