gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 01:58:37 25 4
gpt4 key购买 nike

我正在尝试使用以下行将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com