1. 从后台读取xml数据,读取结果,话不多说,直接上代码

    var kk = "<root><satellite>GF3</satellite><sensor>SAR</sensor><level>LEVEL1A</level><startTime>2017-01-20 11:02:34.571182</startTime><endTime>2017-01-20 11:02:43.420619</endTime><cloudPercent>0</cloudPercent><gsd>5</gsd><topLeftLat>34.977452</topLeftLat><topLeftLong>105.190206</topLeftLong><topRightLat>35.058405</topRightLat><topRightLong>105.773972</topRightLong><bottomRightLat>34.484358</bottomRightLat><bottomRightLong>105.890447</bottomRightLong><bottomLeftLat>34.403121</bottomLeftLat><bottomLeftLong>105.310854</bottomLeftLong></root>"
    xml2js.parseString(kk, function (err, result) {
      console.dir(result.root.bottomLeftLat[0]); // Prints JSON object!

结果如下图:

2. 前端json数据转换成xml数据传到后台

 var mm = {
      root: {
        bottomLeftLat: ["34.403121"],
        bottomLeftLong: ["105.310854"],
        bottomRightLat: ["34.484358"],
        bottomRightLong: ["105.890447"],
        cloudPercent: ["0"],
        endTime: ["2017-01-20 11:02:43.420619"],
        gsd: ["5"],
        level: ["LEVEL1A"],
        satellite: ["GF3"],
        sensor: ["SAR"],
        startTime: ["2017-01-20 11:02:34.571182"],
        topLeftLat: ["34.977452"],
        topLeftLong: ["105.190206"],
        topRightLat: ["35.058405"],
        topRightLong: ["105.773972"]
    var outxml = builder.buildObject(mm).toString();

结果如下图所示:

1. 从后台读取xml数据,读取结果,话不多说,直接上代码 var kk = "&lt;root&gt;&lt;satellite&gt;GF3&lt;/satellite&gt;&lt;sensor&gt;SAR&lt;/sensor&gt;&lt;level&gt;LEVEL1A&lt;/level&gt;&lt;startTime&gt;2017-01-20 11:02:34.... [{'name':'John','surname':'Doe','age':31,'city':'New York'}, {'name':'Jane','surname':'Doe','age':26,'city':'Seattle'}, {'name':'Dave','surname':'Smith','age':45,'ci...
用于将文本转换为 XML 到 Javascript 的角度过滤器 该模块为 Angular 提供text2xmlxml2js过滤器。 它使用浏览器的 DOMParser(在 IE 的情况下使用 XMLDOM ActiveX 组件)。 没有像 X2JS 这样的依赖。 bower install --save angular-xml2js XML JSON 示例 对于以下 XML 文档 <?xml version="1.0"?> <a>4711</a> javascript 对象将被转换
    if (window.DOMParser) {         Standard tmp = new DOMParser();         xml = tmp.parseFromString(data, "text/xml");     } else {         // IE 
function success(result){ if(typeof(result) == "object"){ result = result.lastChild.firstChild.nodeValue;//xml取节点值 eval("result = "+result);//转换为json对象 echart相关操作xAxis,yAxis,series,grid,(包括x轴样式,y轴样式,折现样式,网格样式,折现阴影,折线上方显示数据,x轴文字倾斜,图例,标题, tooltip文字自定义) 22580