SVG图像的xlink:href属性中的&符(&)? [英] Ampersands (&) in xlink:href attributes of SVG images?

查看:467
本文介绍了SVG图像的xlink:href属性中的&符(&)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个包含各种图像标签的SVG文档.图像的 xlink:href (源URL)属性包含带有&符号的查询字符串.如果我将它们转义为%26 或ascii编码? ,则它们不是有效的查询字符串,并且服务器将不会传送该图像.我无法使用CDATA对其进行转义,因为它们是属性(而不是节点).我尝试在image标签内创建一个 xlink:href 节点,但是SVG解析器将其忽略.我想使用纯SVG(而不是HTML内的SVG),以便以后可以转换为JPG,因此脚本编写工作就结束了...

I'm building an SVG document which contains various image tags. The xlink:href (source URL) attributes for the images contain query strings with ampersands. If I escape them as %26 or the ascii encoding ? they're not valid query strings and the server won't deliver the image. I can't escape them with CDATA because they're attributes (not nodes). I've tried creating an xlink:href node within the image tag but that get's ignored by the SVG parser. I want to use pure SVG (not SVG within HTML) so that I can convert to a JPG later, thus scripting is out...

关于如何使以下工作有效的任何提示?

Any hints on how I can make the below work?

<image x="0" y="0" width="306" height="306" xlink:href="http://host.com/image.jpg?token=asdf&expiration=9384029&etc=etc"/>

谢谢!

推荐答案

解决方案是用正确的ascii代码#38 #63 (这是一个问号'?'),如我在误读此问题后最初尝试使用的那样:

The solution is to replace the ampersands with the correct ascii code #38 and Not #63 (which is a question mark '?') as I had initially tried after mis-reading this question: using "?" in SVG href

感谢Stunti https://stackoverflow.com/users/54949/stunti

http://www.ascii.cl/htmlcodes.htm

这篇关于SVG图像的xlink:href属性中的&符(&amp;)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆