I am trying to capture any XML tags in this sample. But if I try to grab anything other than data in the first record in IE, then I can not do that. How do I write javascript to fix this? I suggest using it - it's really all browser compatible. Try this: & lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-885 9-1" & gt; & Lt; Title & gt; Get any XML tags & lt; / Title & gt; & Lt; Script type = 'text / javascript' src = 'http: //imaginationeverywhere.info/jslib//dev/jquery-1.5.1.js'> & Lt; / Script & gt; & Lt; Script type = "text / escapemaite" & gt; Function getData () {var XMLHTTPRequestObject = false; If (window.XMLHTTPRequest) {XMLHTTPRequestObject = new XMLHttpRequest (); } And if (window.ActiveXObject) {XMLHTTPRequestObject = New ActiveXObject ('Microsoft.XMLHTTP'); } If (XMLHTTPRequestObject) {XMLHTTPRequestObject.open ('GET', 'http://imaginationeverywhere.info/xml/cd_catalog.xml', is true); XMLHTTPRequestObject.onreadystatechange = function () {if (XMLHTTPRequestObject.readyState == 4 and XMLHTTPRequestObject.status == 200} {var xmlDocument = XMLHTTPRequestObject.responseXML; displayArtist (XmlDocument);}} XMLHTTPRequestObject.send (tap);}} Function display artist (xmldoc) {titleName = xmldoc.getElementsByTagName ('TITLE'); artistname = xmldoc.getElementsByTagName ('ARTIST'); countryname = xmldoc.getElementsByTagName ('COUNTRY'); CompanyName = xmldoc.getElementsByTagName ('company') ; Name = xmldoc.getElementsByTagName ('PRICE'); YearName = xmldoc.getElementsByTagName ('YEAR'); DisplayTitle = "This is the name of the song title" + Title name [0]. Firstchild.nodeValue + "."; " ; DisplayArtist = "Artist's name" + Artist name [0]. Firstchild.nodeValue + "." ; DisplayCountry = "Artist Country Name" + Country Name [first]. Child. Nodewevil + "."; DisplayCompany = "Artist Company Name" + Company Name [0] First Child.Node Valle + "."; DisplayPrice = "This song is worth $" + Value name [0]. First Child. NodeValue + "."; "; DisplayYear =" This song was released "+ Name of the year [0] First Chald.NodeView +". ";" Target = document.getElementById ('targetDiv'); Target.innerHTML = displayTitle + "
" + Display artist + "
" + Display + "
+ DisplayCompany + "
" + DisplayPrice + "
" + Display year; } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H3 & gt; Get tag value & lt; / H3 & gt; & Lt; Form action = "#" & gt; & Lt; Input type = "button" value = 'get artist name onclick = "getData ()" /> & Lt; / Form & gt; & Lt; Div id = "targetDiv" style = "width: 300px; height: 20px" & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment