欧美整片AⅤ免费_综合亚洲欧美日韩一区二区_久久国产午夜精品理论片应用_人人九九精品国产-日本一区二区视频在线观看,69av视频在线,精品黄色录像,久久久久久久久久久久久久久

JS實現(xiàn)xml與json互轉(zhuǎn)且基本保持原樣

2019-11-8    seo達人



如果非要代碼實現(xiàn)的話,github上一個不錯的js庫(X2JS):https://github.com/abdolence/x2js

自己寫了demo測試了一下:



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

</head>

<body>

</body>

<script src="js/xml2json.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

var xmlText =

'<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="2" value="" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1"><mxGeometry x="220" y="90" width="120" height="80" as="geometry"/></mxCell><mxCell id="3" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1"><mxGeometry x="410" y="110" width="80" height="80" as="geometry"/></mxCell></root></mxGraphModel>';

console.log("原始數(shù)據(jù)xml:"+xmlText);

var x2js = new X2JS();

var jsonObj = x2js.xml_str2json( xmlText );

console.log(jsonObj);

var xmlAsStr = x2js.json2xml_str( jsonObj );

console.log(xmlAsStr);

</script>

</html>

效果如下:







基本能還原,只是""變成了'',這個應該問題不大的。






日歷

鏈接

個人資料

藍藍設計的小編 http://www.kadanni.com.cn

存檔