添加前缀:“ds” - SignedXml [英] Add Prefix:"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屋!