Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up reading xml embedded in HTML with JavaScript.

    I`m trying to write XML in HTML and read it with JavaScript,
    but it`s not working.
    please help.

    my XML in HTML.
    Code:
    <xml id="xmldata" style='display:none;'>
    <markers>
    <marker lat="50.895842" lng="-1.4051" html="text"/>
    </markers>
    </xml>
    Javascript trying to read my XML.
    Code:
    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);
              }

  • #2
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •