svg - 使用 d3 获取 inkscape 属性

标签 svg d3.js inkscape

我需要提取使用 Inkscape 创建的 SVG 文件中的组节点的 inkscape 标签属性:

SVG:

<g id="g123" inkscape:label="group 1">...</g>

代码:

d3.select("#g123").attr("inkscape:label"); // return null

注册 inkscape 命名空间也不起作用:

d3.ns.prefix.inkscape = "http://www.inkscape.org/namespaces/inkscape";
d3.select("#g123").attr("inkscape:label"); // return null

尽管这有效:

d3.select("#g123").node().getAttribute("inkscape:label")

我在这里做错了什么?

最佳答案

试试这个:

d3.select("#g123").node().getAttribute(":inkscape:label")

阅读这篇文章了解原因:12 .

关于svg - 使用 d3 获取 inkscape 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17100480/

相关文章:

svg - 如何将 Inkscape 中的 SVG 大小从 A1 调整为 A0

html - 如何在 SVG 文件中查找相邻路径?

python - 从 SVG 文件创建开罗路径

javascript - 滚动锁定时滚动的 CSS/JS 动画

d3.js - 如何在 d3 工具的强制布局中可视化 mysql 数据库中的数据

javascript - 循环遍历数组并删除特定类型的元素 d3.js

javascript - 如何使用 jQuery 选择在 <text> 中具有特定文本的特定 <g> 作为其子级?

python - 如何在 NetworkX 中创建树并在 D3.js 中显示它

graphics - 墨景 : How to ' crop ' something before 'saving' it?

command-line - 如何使用inkscape命令行界面?