HighTechTalks DotNet Forums  

display encoded xml attribute with javascript

Dotnet XML microsoft.public.dotnet.xml


Discuss display encoded xml attribute with javascript in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
xke
 
Posts: n/a

Default display encoded xml attribute with javascript - 10-26-2007 , 11:53 AM






My xml is a collection of events:

<events>
<event name="event1" />
<event name="event2" />
</events>

I have a JavaScript function looping through the xml and building a
list with the event names.
<div id='myDiv' />

<script js>
.... code ...
.... loop ..
{
document.getElementById('myDiv').innerHTML +=
'<li>'+objXMLNode.getAttribute('name')+'</li>';
}
... code ...
</script>

Everything works fine but I'd like now to have some events name as URL
links:

<events>
<event name="event1" />
<event name="&lt;a href=&quot;index.aspx?param=1&quot;
class=&quot;content_display&quot;&gt;SECOND EVENT&lt;/a&gt;" />
</events>

This is the XML created on the backend to be passed to the client
(maybe HTMLEncode is not the best idea ?).
However using the same JS function, loop through nodes and in the list
I get:

*event1
*<a href='index.aspx?param=1'>SECOND EVENT</a>

How can I tell the browser to actually display the link for the second
item?

Thanks,
xke


Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: display encoded xml attribute with javascript - 10-26-2007 , 12:30 PM






xke wrote:

Quote:
Everything works fine but I'd like now to have some events name as URL
links:

events
<event name="event1" /
<event name="&lt;a href=&quot;index.aspx?param=1&quot;
class=&quot;content_display&quot;>SECOND EVENT&lt;/a>" /
/events

This is the XML created on the backend to be passed to the client
(maybe HTMLEncode is not the best idea ?).
However using the same JS function, loop through nodes and in the list
I get:

*event1
*<a href='index.aspx?param=1'>SECOND EVENT</a

How can I tell the browser to actually display the link for the second
item?
If your code really sets innerHTML then I don't understand why you do
not get a link. The result you see would occur if you set innerText or
used document.createTextNode().


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
xke
 
Posts: n/a

Default Re: display encoded xml attribute with javascript - 10-26-2007 , 01:43 PM



Exactly, I don't know either why it doesn't come up as a link but as a
literal: <a href='....'>some link</a>
However I complicated my XML a bit more by sending the link as a
separate attribute and check/display/construct the link based on the
new attribute.

Thanks for answering,
xke

On Oct 26, 12:30 pm, Martin Honnen <mahotr... (AT) yahoo (DOT) de> wrote:
Quote:
xke wrote:
Everything works fine but I'd like now to have some events name as URL
links:

events
event name="event1" /
event name="&lt;a href=&quot;index.aspx?param=1&quot;
class=&quot;content_display&quot;>SECOND EVENT&lt;/a>" /
/events

This is the XML created on the backend to be passed to the client
(maybe HTMLEncode is not the best idea ?).
However using the same JS function, loop through nodes and in the list
I get:

*event1
*<a href='index.aspx?param=1'>SECOND EVENT</a

How can I tell the browser to actually display the link for the second
item?

If your code really sets innerHTML then I don't understand why you do
not get a link. The result you see would occur if you set innerText or
used document.createTextNode().

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/- Hide quoted text -

- Show quoted text -



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.