作者:ayo | 来源:互联网 | 2023-06-11 16:43
Imhavingtroubleconvertingsomexmldatatojsondataintheformatitisexpected.Imnewtoal
I'm having trouble converting some xml data to json data in the format it is expected. I'm new to all of these techniques and the resources I find online are difficult for me to decypher. Using the app I make in my plnkr, I can take the data in the data.json
file and use it to create the chart using a charts library. I have the xml in the data.xml
file - I think that it is in the correct format in order to be converted to json in the required format. How do I use the x2js library in order to convert the xml to json and implement it into my chart? I've been stuck on this for a while now, and haven't been able to figure out how to get it working.
我无法以预期的格式将一些xml数据转换为json数据。我是所有这些技术的新手,我在网上找到的资源对我来说很困难。使用我在plnkr中创建的应用程序,我可以获取data.json文件中的数据并使用它来使用图表库创建图表。我在data.xml文件中有xml - 我认为它的格式正确,以便以所需的格式转换为json。如何使用x2js库将xml转换为json并将其实现到我的图表中?我现在已经坚持了一段时间,并且无法弄清楚如何让它发挥作用。
Currently, the app takes the data.json
file and implements it into the data for the charts. What is the easiest way to take the xml and do the same?
目前,该应用程序获取data.json文件并将其实现为图表的数据。采取xml并执行相同操作的最简单方法是什么?
Edit: I've updated my plnkr with my attempt at converting the xml data to json. I even tried simply printing out the final data in json form - if the xml converted to json, but nothing came up. I entered a x2js.js
file that has the functions from the library needed for the conversion I used in the service. I get the following error:
编辑:我已经尝试将xml数据转换为json,更新了我的plnkr。我甚至尝试简单地以json格式打印出最终数据 - 如果xml转换为json,但什么都没有出现。我输入了一个x2js.js文件,其中包含我在服务中使用的转换所需的库中的函数。我收到以下错误:
ReferenceError: data is not defined
at new (script.js:38)
at invoke (code.angularjs.org/1.2.2/angular.js:3641)
at Object.instantiate (code.angularjs.org/1.2.2/angular.js:3653)
at code.angularjs.org/1.2.2/angular.js:6684
at code.angularjs.org/1.2.2/angular.js:6097
at forEach (code.angularjs.org/1.2.2/angular.js:307)
at nodeLinkFn (code.angularjs.org/1.2.2/angular.js:6084)
at compositeLinkFn (code.angularjs.org/1.2.2/angular.js:5550)
at compositeLinkFn (code.angularjs.org/1.2.2/angular.js:5553)
at publicLinkFn (code.angularjs.org/1.2.2/angular.js:5458)
If anyone can help me out, its greatly appreciated.
如果有人可以帮助我,它非常感谢。
1 个解决方案