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

03-24-2009, 10: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;'>
<marker lat="50.895842" lng="-1.4051" html="text"/>

Javascript trying to read my XML.

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);


03-24-2009, 01: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.