Discuss this help topic in SecureBlackbox Forum

XML: Add reference to element of external XML file

To add the reference to XML document part in the external XML file you need to set string value, which uniquely identifies the referenced element to TElXMLReference.URI property. Next you need to load the XML file to TElXMLDOMDocument object, and then put a reference to this element to TElXMLReference.URINode property, which will be used for reference computation.

C#:


TElXMLDOMDocument tempDocument = new TElXMLDOMDocument();
TElXMLReference Ref = new TElXMLReference();

tempDocument.LoadFromFile("sample.xml");
Ref.URI = "file://sample.xml#id-1";
Ref.URINode = SBXMLUtils.FindElementById(tempDocument.DocumentElement, "id-1");
Signer.References.Add(Ref); // add the reference to TElXMLSigner object
Delphi:

tempDocument := TElXMLDOMDocument.Create();
tempDocument.LoadFromFile('sample.xml');
Ref := TElXMLReference.Create();
Ref.URI := 'file://sample.xml#id-1';
Ref.URINode := SBXMLUtils.FindElementById(tempDocument.DocumentElement, 'id-1');
Signer.References.Add(Ref); // add the reference to TElXMLSigner object
...
// when signing is finished we need to clear temporary xml document object
tempDocument.Free();

How To articles about XML signing (XMLDSig and XAdES)

Discuss this help topic in SecureBlackbox Forum