如何添加“:"(命名空间前缀)在 Xxml 中的 XAttribute 名称中 [英] How To Add ":" (namespace prefix) in XAttribute Name in Xml
问题描述
我有一个 xml 文件并在 Silverlight 中使用.
i have one xml file and using in silverlight.
doc.Descendants(xamlparent).FirstOrDefault().Add(new XAttribute("x:Class","WorkflowConsoleApplication1.modify"));
但是在这个:"十六进制导致错误.如何在属性名称中添加这个十六进制.这可能吗?.
but in this ":" hexadecimal cause error.how can i add this hexadecimal in attribute name.is this possible ?.
推荐答案
您必须查看映射到 x
命名空间前缀的命名空间的 URI.检查 XML 文档的顶部,它会包含类似 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
的内容.
You have to see the URI of the namespace which is mapped to the x
namespace prefix. Check out the top of your XML document, it will contain something like xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
.
然后,使用上面的完整 XML 命名空间 URI 实例化 XAttribute
,如下所示:
Then, you instantiate the XAttribute
using the full XML namespace URI from above like so:
new XAttribute(XName.Get("Class", "http://schemas.microsoft.com/winfx/2006/xaml"), "WorkflowConsoleApplication1.modify")
进一步阅读:
这篇关于如何添加“:"(命名空间前缀)在 Xxml 中的 XAttribute 名称中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!