【发布时间】:2016-06-16 13:24:59
【问题描述】:
我在一个函数的数组中将以下对象传递给我:
[ { id: 'WA1WA1WAbWA2WAaWAbWA9WA6-WAdWA2WAaWAd-4WAbWAcWA3-WAbWA3WA7WAa-WAcWAbWA8WA9WAcWA9WA9WA9WA3WA3WA3WA9',
obj: '<svg data="BusinessProductFigure" x="484.171875" y="123" id="WA1WA1WAbWA2WAaWAbWA9WA6-WAdWA2WAaWAd-4WAbWAcWA3-WAbWA3WA7WAa- WAcWAbWA8WA9WAcWA9WA9WA9WA3WA3WA3WA9"
xmlns="http://www.w3.org/2000/svg" version="1.1"><rect x="4" y="4"
width="60" height="14" fill="rgb(299,299,162)" stroke-linejoin="round"
stroke="rgb(299,299,162)" stroke-width="1"/></svg>' } ]
是否可以在 SVG 标记内的单独变量中获取 X 和 Y 值?是否有任何条件或分隔符可以以某种方式使用?
【问题讨论】:
-
使用DOMParser解析它,然后从DOM中读取值。
-
@RobertLongson 我得到了文档,但我现在如何访问各个变量?
-
我想通了。刚刚使用 doc.getElementsByTagName["svg"].getAttribute("x");非常感谢!
标签: javascript arrays object svg delimiter