SignedXml.LoadXml(XmlElement) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Läser in ett SignedXml tillstånd från ett XML-element.
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)
Parametrar
- value
- XmlElement
XML-elementet som tillståndet ska läsas SignedXml in från.
Undantag
Parametern value är null.
Parametern value innehåller inte en giltig SignatureValue egenskap.
-eller-
Parametern value innehåller inte en giltig SignedInfo egenskap.
Exempel
Följande kodexempel visar hur du använder LoadXml metoden för att verifiera ett XML-dokument.
// 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