开发者

Javascript Is It Possible to Get XML Count?

开发者 https://www.devze.com 2023-03-24 09:05 出处:网络
I am using Google Maps and am creating a set of markers from a parsed XML file. Is it possible for the javascript to get a count of the marker? Or should I do this in SQL?

I am using Google Maps and am creating a set of markers from a parsed XML file. Is it possible for the javascript to get a count of the marker? Or should I do this in SQL?

Here is the javascript:

   var xml = parseXml(data);
   var markerNodes = xml.documentElement.getElementsByTagName("marker");
   var bounds = new google.maps.LatLngBounds();

Here is a sample of the XML:

<markers>
<marker name="Banner Churchill Community Hospital" address="801 East Williams Avenue" city="Fallon" state="NV" zipcode="89406" telephone="7754233151" lat="39.475056" lng="-118.766434" images="./thumbnails/placeholder.jpg" url="www.yahoo.com" />
<marker name="Boulder City Hospital" address="901 Adams Blvd" city="Boulder City" state="NV" zipcode="89005" telephone="7022934111" lat="35.968273" lng="-114.84185" images="./thumbnails/placeholder.jpg" url="www.yahoo.com" /> 
</markers>

I am unsure if javascript coul开发者_Go百科d get a total count of the markers, or if I need to do this in the SQL query. Thanks, --Matt


Maybe I haven't understood your question properly, but markerNodes.length will tell you how many "marker" nodes you have found in the xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消