SignedXml.LoadXml(XmlElement) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 XML 元素加载 SignedXml 状态。
public:
void LoadXml(System::Xml::XmlElement ^ value);
public void LoadXml (System.Xml.XmlElement value);
member this.LoadXml : System.Xml.XmlElement -> unit
Public Sub LoadXml (value As XmlElement)
参数
- value
- XmlElement
要从其加载 SignedXml 状态的 XML 元素。
例外
value
参数为 null
。
示例
下面的代码示例演示如何使用 LoadXml 方法来验证 XML 文档。
// Verify the signature of an XML file and return the result.
Boolean VerifyDetachedSignature( String^ XmlSigFileName )
{
// Create a new XML document.
XmlDocument^ xmlDocument = gcnew XmlDocument;
// Load the passed XML file into the document.
xmlDocument->Load( XmlSigFileName );
// Create a new SignedXMl object.
SignedXml^ signedXml = gcnew SignedXml;
// Find the "Signature" node and create a new
// XmlNodeList object.
XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" );
// Load the signature node.
signedXml->LoadXml( safe_cast<XmlElement^>(nodeList->Item( 0 )) );
// Check the signature and return the result.
return signedXml->CheckSignature();
}
// Verify the signature of an XML file and return the result.
public static Boolean VerifyDetachedSignature(string XmlSigFileName)
{
// Create a new XML document.
XmlDocument xmlDocument = new XmlDocument();
// Load the passed XML file into the document.
xmlDocument.Load(XmlSigFileName);
// Create a new SignedXMl object.
SignedXml signedXml = new SignedXml();
// Find the "Signature" node and create a new
// XmlNodeList object.
XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature");
// Load the signature node.
signedXml.LoadXml((XmlElement)nodeList[0]);
// Check the signature and return the result.
return signedXml.CheckSignature();
}
' Verify the signature of an XML file and return the result.
Public Shared Function VerifyDetachedSignature(XmlSigFileName As String) As [Boolean]
' Create a new XML document.
Dim xmlDocument As New XmlDocument()
' Load the passed XML file into the document.
xmlDocument.Load(XmlSigFileName)
' Create a new SignedXMl object.
Dim signedXml As New SignedXml()
' Find the "Signature" node and create a new
' XmlNodeList object.
Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature")
' Load the signature node.
signedXml.LoadXml(CType(nodeList(0), XmlElement))
' Check the signature and return the result.
Return signedXml.CheckSignature()
End Function