...

View Full Version : reading xml embedded in HTML with JavaScript.



deluxmilkman
03-24-2009, 09:18 AM
I`m trying to write XML in HTML and read it with JavaScript,
but it`s not working.
please help.

my XML in HTML.


<xml id="xmldata" style='display:none;'>
<markers>
<marker lat="50.895842" lng="-1.4051" html="text"/>
</markers>
</xml>


Javascript trying to read my XML.



document.getElementById('xmldata');
if(xml.documentElement == null)
xml.documentElement = xml.firstChild;

var markers = xmlDoc.documentElement.getElementsByTagName("marker");

for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var html = markers[i].getAttribute("html");


// create the marker
var marker = createMarker(point,label,html);
map.addOverlay(marker);
}

:thumbsup:

freedom_razor
03-24-2009, 12:01 PM
Is that page only for IE users? XML embedded in HTML is called XML Data Islands and is IE only technology, though you could simulate it in FF somehow I suppose.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum