简体   繁体   English

使用d3js显示XML数据

[英]Show XML data with d3js

i'm working on a little d3.js asignment for school.. I looked at some examples to load a XML file, but I can't figure it out what i'm doing wrong.. The XML file is loading correct.. I'm just figuring out JS so please not to technical ;p.. 我正在为学校准备一些d3.js作业。我看了一些加载XML文件的示例,但我无法弄清楚我做错了什么。XML文件正在正确加载。我只是想弄清楚JS,所以请不要使用技术; p ..

this is the code: 这是代码:

d3.xml("data.xml", "application/xml", function(xml) {

    var data = d3.select(xml).selectAll("path");

    console.log("data uit de xml=  " + data);

});

Thanx! 谢谢!

Assuming that you have path elements in your XML, you would select them like this: 假设您的XML中包含path元素,则可以这样选择它们:

var data = xml.path;

The XML data is returned as a JavaScript object. XML数据作为JavaScript对象返回。 It might be easiest to log the entire object and look at it in the debugger/JavaScript console of the browser of your choice. 记录整个对象并在您选择的浏览器的调试器/ JavaScript控制台中查看它可能是最简单的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM