
April 15th, 2008, 03:51 PM
|
 |
Haphazardly programming
|
|
Join Date: Nov 2004
Location: Louisville, KY
|
|
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.
|