SignedXml.LoadXml(XmlElement) Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Carga un SignedXml estado de un elemento XML.
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)
Parámetros
- value
- XmlElement
Elemento XML desde el que se va a cargar el SignedXml estado.
Excepciones
El value parámetro es null.
El value parámetro no contiene una propiedad válida SignatureValue .
O bien
El value parámetro no contiene una propiedad válida SignedInfo .
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar el LoadXml método para comprobar un documento XML.
// 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