在 SVG 中创建表格

问题描述:

我正在尝试在 SVG 文档中创建一个类似表格的对象.目前,由于 SVG 没有表格元素,我使用 HTML 解析器将 HTML 表格(由用户在 HTML 表格生成器中创建)转换为一组 SVG 对象,并且然后将其添加到我的整体 SVG 绘图中.我想知道是否有人能够找到这种方法的更好替代方法,例如 SVG 表构建器?我希望使用 Javascript 或 jquery 来完成此操作.任何想法或建议将不胜感激.

I'm trying to create a table-like object within an SVG document. Currently, due to the fact that SVG does not have a table element, I am using an HTML parser to go through and convert an HTML table, (created by the user in an HTML table Builder), to a group of SVG objects, and then adding that to my overall SVG drawing. I was wondering if any one was able to find a better alternative to this method, such as an SVG table builder? I'm looking to accomplish this using Javascript or jquery. Any ideas or suggestions would be appreciated.

我只想在我的 SVG 中嵌入一个真实的表格:

I would simply embed a real table in my SVG:

<?xml version="1.0" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg">
  <foreignObject x="10" y="10" width="100" height="150">
    <body xmlns="http://www.w3.org/1999/xhtml">
      <table><!-- ... --></table>
    </body>
  </foreignObject>
  <!-- ... -->
</svg>