JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 15th, 2008, 03:51 PM
Ziptnf's Avatar
Ziptnf Ziptnf is offline
Haphazardly programming
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Louisville, KY
Posts: 204 Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 19 h 38 m 29 sec
Reputation Power: 31
Send a message via AIM to Ziptnf Send a message via MSN to Ziptnf Send a message via Yahoo to Ziptnf
Thumbs down Javascript picky about XML tag value length?

Hey, guys. I'm using Javascript to parse an XML file with some links in it, and just printing it out onto the page. Very simple.

Code:
<script language="javascript" type="text/javascript">
var xmlDoc;
if(navigator.appName == "Netscape") {
	var xmlDoc = document.implementation.createDocument('','doc',null);
	var objXMLHTTP = new XMLHttpRequest();
	objXMLHTTP.open("GET", "/structure/xmloffers/vacations.xml", false);
	objXMLHTTP.send(null);
	xmlDoc = objXMLHTTP.responseXML;
}
if(navigator.appName == "Microsoft Internet Explorer") {
	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async = "false";
	xmlDoc.load("/structure/xmloffers/vacations.xml");
}
var i = 0;
var url = xmlDoc.getElementsByTagName("url");
for(i = 0; i < url.length; i++) {
	var urlvalue = xmlDoc.getElementsByTagName("urlvalues")[i].childNodes[0].nodeValue;
	var urlname = xmlDoc.getElementsByTagName("urlnames")[i].childNodes[0].nodeValue;
	document.write("<font='arial' size='25px'><a href=" + urlvalue + " target='_blank'>" + urlname + "</a></font><br>");
	}
</script>  


The XML file it's parsing looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<links>
<url>
<urlvalues>'http://www.latesttraveloffers.com/lton/ltonclct.asp?distributorcode=TVWCWT&distributoraccount=TVWCWT&OfferId=1077782&GotoOffer=True'
</urlvalues>
<urlnames>Swim with the dolphins with American Express Vacations!</urlnames>
</url>
(etc etc etc)...
</links>


Not too hard to figure out, right? Pretty straightforward. Basically, the Javascript gets the values in the <urlvalues> and <urlnames> tags and prints them out into a handy little link the user can click. The problem is, the URL in <urlvalues> is apparently too long, because shorter URL's can be parsed, but not ones of that length. For example, "http://google.com" will work, but the one that I have won't. Is anybody aware of this problem? Any help is appreciated.

Reply With Quote
  #2  
Old April 16th, 2008, 07:21 AM
KorRedDevil's Avatar
KorRedDevil KorRedDevil is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2005
Location: Bucharest ROMANIA
Posts: 2,557 KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level)KorRedDevil User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 5 h 34 m 26 sec
Reputation Power: 614
Send a message via Yahoo to KorRedDevil
The problem is not the length, but the special characters used in that link. In XML normal texts (strings) you should not use plain < > " ' or & characters, as they are interpreted as XML entities.

In XML strings you should replace:
Code:
& with &amp ;
< with &lt ;
> with &gt ;
" with &quot ;
' with &#39 ;


- remove the space before the colon ' ;' . I used that to avoid a literal interpretation in the forum's framework
__________________
HELP SAVE ANA

Last edited by KorRedDevil : April 16th, 2008 at 07:27 AM.

Reply With Quote
  #3  
Old April 16th, 2008, 07:37 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,874 Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 24 m 7 sec
Reputation Power: 2569
lol

What KorRedDevil meant was the ascii codes for the symbols but the forums parsed them into the symbols.

& with & #38;
< with & #60;
> with & #62;
" with & #34;
' with & #39;


[EDIT] Ah, you updated when I posted ^^
__________________
[PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

W3Fools - A W3Schools Intervention.

Reply With Quote
  #4  
Old April 16th, 2008, 10:32 AM
Ziptnf's Avatar
Ziptnf Ziptnf is offline
Haphazardly programming
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Louisville, KY
Posts: 204 Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level)Ziptnf User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 19 h 38 m 29 sec
Reputation Power: 31
Send a message via AIM to Ziptnf Send a message via MSN to Ziptnf Send a message via Yahoo to Ziptnf
Thanks, guys. That did it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Javascript picky about XML tag value length?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap