开发者社区> 问答> 正文

js怎么读取和解析从sqlServer读取的xml字符串??报错

 var xmlStr=record.get('xInfo');

alert(xmlStr);

alert出来的字符串如下:

<profile>
  <f1_date>sffdsf</f1_date>
  <f2_Appl>dfsfsdf</f2_Appl>
  <f3_orign>sfsdffffff</f3_orign>
  <f17_typeOfProduct>1</f17_typeOfProduct>
</profile>

这个怎么获取每一个tagName和text啊?

使用这个var elements = xmlDoc.getElementsByTagName("profile");报错为什么啊?



展开
收起
爱吃鱼的程序员 2020-06-14 21:18:30 606 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    对IE:

    xmlDoc=newActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(txt);
    对firefox:

    parser=newDOMParser();xmlDoc=parser.parseFromString(txt,"text/xml");

    可以参考一下这个,用Jquey解析xml

    http://www.nowamagic.net/jquery/jquery_ParsingXmlData.php

    http://zhangjun817.duapp.com/#/article/info/ef1b5fb7-e1d1-4838-a1df-f74b67c63581
    2020-06-14 21:18:48
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
JavaScript异步编程 立即下载
Delivering Javascript to World 立即下载
编程语言如何演化-以JS的private为例 立即下载

相关镜像