Actionscript 3 svg XML 解析错误?
嘿,当使用下面的 foreach 循环时,我得到了两个不同的结果。
据我所知,除了两个 XML 文本中的属性之外,没有任何区别。
for each (var pathXML:XML in svg.path)
{
// do stuff... trace(pathXML.@stroke)
}
// This one works, the loop iterates once over the single path element...
var svg:XML =
<svg>
<path stroke="#00FF00" />
</svg>
// This one doesn't, the loop just exits.
var svg:XML =
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="612px" height="792px" viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">
<path fill="#FFFFFF" stroke="#000000" d="M160.333,372.444c0,0,17.778-115.555,60-63.333s27.778-106.666,78.889,40" />
</svg>
Hey I get two different results when using the for each loop below.
As far as I can tell there's no difference aside from attributes in the two XML literals.
for each (var pathXML:XML in svg.path)
{
// do stuff... trace(pathXML.@stroke)
}
// This one works, the loop iterates once over the single path element...
var svg:XML =
<svg>
<path stroke="#00FF00" />
</svg>
// This one doesn't, the loop just exits.
var svg:XML =
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="612px" height="792px" viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">
<path fill="#FFFFFF" stroke="#000000" d="M160.333,372.444c0,0,17.778-115.555,60-63.333s27.778-106.666,78.889,40" />
</svg>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不同之处在于您的第二个 XML 使用命名空间。您可以在此处找到解决方案。希望有帮助。
The difference is that your second XML are using a namespace. You can find a solution here. Hope it helps.