js如何解析xml字符串?
如字符串:--------------------------------------------------------<markers><markercarId="1...
如字符串:
--------------------------------------------------------
<markers>
<marker carId="1" carName="SHANGHAI" gpsTime="2011-08-26 21:21:11.0" lat="31.230393" lng="121.473704" direction="222" speed="22" />
<marker carId="7" carName="XIAMEN" gpsTime="2011-08-26 21:21:11.0" lat="24.479836" lng="118.089421" direction="222" speed="22" />
</markers>
-----------------------------------------------------------
用js的var dom = new ActiveXObject("Microsoft.XMLDOM");
不行,
怎么办? 展开
--------------------------------------------------------
<markers>
<marker carId="1" carName="SHANGHAI" gpsTime="2011-08-26 21:21:11.0" lat="31.230393" lng="121.473704" direction="222" speed="22" />
<marker carId="7" carName="XIAMEN" gpsTime="2011-08-26 21:21:11.0" lat="24.479836" lng="118.089421" direction="222" speed="22" />
</markers>
-----------------------------------------------------------
用js的var dom = new ActiveXObject("Microsoft.XMLDOM");
不行,
怎么办? 展开
1个回答
展开全部
这个不知道哇
追问
var xmlResponsedd = xmlRequest.responseText;
var xmlDoc = parseXML(xmlResponsedd);
for (var i = 0; i < xmlDoc.getElementsByTagName("marker").length; i++)
{
var trackerNo = xmlDoc.getElementsByTagName("marker")[i].getAttribute("carId");
var trackerName = xmlDoc.getElementsByTagName("marker")[i].getAttribute("carName");
}
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询