Performs C14N transformation of XML document (file-to-file with options).

Namespace:  Sc14n
Assembly:  diSc14nNet (in diSc14nNet.dll) Version: (


public static int ToFile(
	string outFile,
	string xmlFile,
	string nameOrId,
	Tran tranOpt
Visual Basic (Declaration)
Public Shared Function ToFile ( _
	outFile As String, _
	xmlFile As String, _
	nameOrId As String, _
	tranOpt As Tran _
) As Integer


Type: System..::.String
Name of output file to create.
Type: System..::.String
Name of input XML file.
Type: System..::.String
To specify the tag name or Id (see remarks below).
Type: Sc14n..::.Tran
Transformation option.

Return Value

0 if successful or non-zero error code.


Use the nameOrId parameter to specify the element of the XML document to include or exclude.

With options ExcludeByTag or SubsetByTag, nameOrId specifies the element's tag name.

  • By default, the first element with a matching tag name will be chosen.
  • To specify the Nth element, write as tagname[N] where N=1,2,3,...
With options ExcludeById or SubsetById, nameOrId specifies the element's Id.
  • The default Id attribute name is Id, so the argument myvalue will find the element with attribute Id="myvalue".
  • To use a different attribute name - for example ID - write in the form ID=myvalue with no quotes.
With option Entire, the parameter is ignored, so just use "" or null.

Exactly one element will be excluded or included. Tag names and Id values are case sensitive. It is an error (NO_DATA_ERROR) if no matching element is found.


// Example 1. Excludes the first element with the tag name <Signature>
r = C14n.ToFile("c14nfile1.txt", "input.xml", "Signature", Tran.ExcludeByTag);

// Example 2. Finds and transforms the first element with the tag name <SignedInfo>
r = C14n.ToFile("c14nfile2.txt", "input.xml", "SignedInfo", Tran.SubsetByTag);

// Example 3. Finds and transforms the third element with the tag name <Data>
r = C14n.ToFile("c14nfile3.txt", "input.xml", "Data[3]", Tran.SubsetByTag);

// Example 4. Finds and transforms the element with attribute Id="foo"
r = C14n.ToFile("c14nfile4.txt", "input.xml", "foo", Tran.SubsetById);

// Example 5. Finds and transforms the element with attribute ID="bar"
r = C14n.ToFile("c14nfile5.txt", "input.xml", "ID=bar", Tran.SubsetById);

// Example 6. Excludes element with attribute Id="thesig"
r = C14n.ToFile("c14nfile6.txt", "input.xml", "thesig", Tran.ExcludeById);

See Also