.net - 使用 .NET XLinq 解析 svg - 'xlink' 是未声明的前缀

标签 .net xml svg linq-to-xml

我正在尝试使用以下行将 svg 字符串解析为 XElement:

XElement productSvg = XElement.Parse(svgString);

但我收到以下异常:XmlException - 'xlink' is an undeclared prefix 这是我的 svg:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<svg id="svg62433" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 595.19 596.32" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
        <g id="g7123">
            <path id="path5588" d="m404.54,164.29c0,121.64-98.612,220.26-220.26,220.26-121.64,0-220.26-98.612-220.26-220.26,0-121.64,98.612-220.26,220.26-220.26,121.64,0,220.26,98.612,220.26,220.26z" transform="matrix(0.01922722,0.99981514,-0.99981514,0.01922722,536.42634,464.95177)" fill="none"/>
            <text id="text5590" style="writing-mode:lr-tb;letter-spacing:0px;text-anchor:middle;word-spacing:0px;text-align:center;" font-weight="bold" font-size="64px" line-height="125%" font-stretch="normal" font-variant="normal" font-style="normal" font-family="'Swis721 Cn BT'">
                <textPath id="textPath5598" xlink:href="#path5588" startOffset="50%">
                    <tspan id="contentTopText" style="writing-mode:lr-tb;text-anchor:middle;text-align:center;" font-weight="bold" font-size="64px" line-height="125%" font-stretch="normal" font-variant="normal" font-style="normal" font-family="'Swis721 Cn BT'">Text Here</tspan>
                </textPath>
            </text>
        </g>
</svg>

有谁知道如何在 .NET XLinq 中成功解析包含命名空间的 xml 属性?

最佳答案

这里有一个很好的解决这个问题的方法,对我来说很完美:

http://aspnetgotyou.blogspot.com/2010/06/xdocument-or-xelement-with-xmlnamespace.html

关于.net - 使用 .NET XLinq 解析 svg - 'xlink' 是未声明的前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9502023/

相关文章:

c# - XPathNavigator.SetValue 抛出 NotSupportedException

javascript - svg - 溢出可见

javascript - 将 SVG 中的组拆分为位于内容周围的子图像

.net - 如何使用 .NET Framework 执行 RSAES-OAEP 加密和解密?

c# - 比较和对比来自 Telerik 的 NHibernate 和 OpenAccess

ruby-on-rails - 为返回 XML 的 Controller 操作编写规范 -- Ruby on Rails

android - 读取和写入 XML 文件

xml - CentOS Epel 错误

javascript - 当光标位于拉斐尔中的另一个图像上时,如何防止鼠标悬停事件在图像上失去焦点?

.net - 新的 asp.net 图表控件 - 它们会与 MVC 一起使用(最终)吗?