473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Insert Hyperlink from XML

Hi,

I'm a newbie to web design, and have been piecing togther a site for a friend over the last few weeks basically by Googling everything I don't understand and trying to fit it all together. It's been an uplifting experince and have picked up some knowledge of MySQL, PHP, XML and AJAX along the way.

I nearly have all of the functionality I need to move forward but there is one thing really annoying me because I can't fix it, and I have had much look searching through usual resources..

Basically, I am dynamically displaying data on my HTML page by reading values from an XML file and writing to HTML using create.textnode().

Everything is working fine except that one of the fields I want to display is a web address and I want this text field to display as a hyperlink on the webpage. So if the XML entry was <webaddress>http://www.hotmail.com</webaddress> I need that to display as a hyperlink to Hotmail on the page. Currently it just gets inserted as a text string.

Example of the code I am using is:

Expand|Select|Wrap|Line Numbers
  1. var webaddress = xmldoc.getElementsByTagName('webaddress').item(1);
  2. txt3 = document.createTextNode(webaddress);
  3. document.getElementById('webaddressdiv').appendChild(txt3);
  4.  
So in the above code I am reading the text value from the XML file, create a text node containing the text string of the webaddress and then writing it to a tag called webaddressdiv.

Any ideas as to how I make this dynamic text string into a dynamic hyperlink ?
Aug 6 '07 #1
1 4498
jkmyoung
2,057 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. var webaddress = xmldoc.getElementsByTagName('webaddress').item(1);  
  2. txt3 = document.createTextNode(webaddress);
  3. document.getElementById('webaddressdiv').appendChild(txt3);
Can you surround it in an anchor <a> tag?
eg like: <a href="www.google.ca">www.google.ca</a>
Expand|Select|Wrap|Line Numbers
  1. anchor = document.createElement("a");
  2. href = document.createAttribute("href");
  3. href.nodeValue = webaddress;
  4. anchor.appendChild(href);
  5. anchor.appendChild(txt3);
  6. document.getElementById('webaddressdiv').appendChild(anchor);
Aug 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: For example John Smith | last post by:
I'm doing a data transfer from Access to SQL Server, I wish to keep the identity column (autonumber) values as all the data is already related. I tried the first table append query including the...
0
by: Koen | last post by:
Hi all, I use 'DoCmd.RunCommand acCmdInsertHyperlink' to be able to insert a hyperlink into my database. The annoying thing is, that the default directory is the same as where my front end .mde...
1
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft...
9
by: Peter Afonin | last post by:
Hello, I created an e-mail form pretty much as described in this article: http://www.4guysfromrolla.com/webtech/080801-1.shtml. It works great, but I cannot figure out one thing: I need to...
0
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif...
1
by: codemanthebarbarian | last post by:
Is there an activeX or DLL that I can use that emulates the Insert Hyperlink GUI of MS Access? I'd hate to have to code all the beauty that's already there.
20
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
3
AllusiveKitten
by: AllusiveKitten | last post by:
Hi I was wondering if it was possible to code in a command to open the browser which will select a file that I want to insert as a hyperlink using a form. I hope this does not sound too...
2
by: adamace5o | last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of $test it does work. I suspect it is something to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.