添加前缀:“ds” - SignedXml [英] Add Prefix:"ds" - SignedXml

查看:180
本文介绍了添加前缀:“ds” - SignedXml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想添加predfix"DS"在带有"SignedXmL"的签名文档中。


有没有办法在签名XML文档的签名(.Net中的SignedXml类)上设置前缀?

Hi,

I want to Add predfix "DS" in signed Document with "SignedXmL".

Is there a way to set the prefix on the Signature of a Signed XML Document (SignedXml class in .Net)?

所以代替:

<Signature xmlns="http://www.w3.org/2000/09/xmldsig#>
...
</Signature>

我可以拥有以下内容:

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#>
...
</ds:Signature>



Thanks

推荐答案

嗨Ouajdi,你可以这样做:

XmlDocument dom = new XmlDocument();

hi Ouajdi,you can make it in this way:

XmlDocument dom = new XmlDocument();

XmlNode root = dom.AppendChild(dom.CreateElement(" ds"," Signature"," http ://www.w3.org/2000/09/xmldsig #"));
root.AppendChild(dom.CreateElement(" ds:Test",root.NamespaceURI))。InnerText ="测试内容";
Console.Write(dom.InnerXml);


您将得到以下内容:
< ds:签名xmlns: ds =" http://www.w3.org/2000/ 09 / xmldsig#">
< ds:Test>测试
内容< / ds:测试>< / ds:签名>

         XmlNode root = dom.AppendChild(dom.CreateElement("ds","Signature","http://www.w3.org/2000/09/xmldsig#"));
         root.AppendChild(dom.CreateElement("ds:Test",root.NamespaceURI)).InnerText = "Test Content";
         Console.Write(dom.InnerXml);


then you will get the following:
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Test>Test Content</ds:Test></ds:Signature>


这篇关于添加前缀:“ds” - SignedXml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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