Skip to content

XML Library

XmlDocument


Description

Represent a document written in XML markup

Methods

LoadFromString(string)

Description

Creates and loads an XML Document object, from a string

Return Type : void

Static : No

Namespace : XmlLib.XmlDocument

Parameters

Name Data Type Description
xmlString string String, representing the file containing the XML document to be loaded

Syntax

string xmlString = 
 "<employee>" +
 "  <firstname>Dwight</firstname>" +
 "  <lastname>Schrute</lastname>" +
 "  <occupation>" +
 "  <title>Assistand TO the Regional Manager</title>" +
 "  <title>Beet Farmer</title>" +
 "  </occupation>" +
 "</employee>";
XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString(xmlString);



SelectElement(string)

Description

Returns an XML Element object, based on a specified XPath Expression. If not exists, returns nothing.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlDocument

Parameters

Name Data Type Description
xpath string The XPath expression

Syntax

string xmlString = 
 "<employee>" +
 "  <firstname>Dwight</firstname>" +
 "  <lastname>Schrute</lastname>" +
 "  <occupation>" +
 "    <title>Assistand TO the Regional Manager</title>" +
 "    <title>Beet Farmer</title>" +
 "  </occupation>" +
 "</employee>";
XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString(xmlString);
XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation/title[1]");



SelectElements(string)

Description

Select a list of Elements matching the XPath expression

Return Type : Collection

Static : No

Namespace : XmlLib.XmlDocument

Parameters

Name Data Type Description
xpath string The XPath Expression

Syntax

XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString("bookstore");
Collection[XmlLib.XmlElement] AustenBooks = xmlDocument.SelectElements("descendant::book[author/last-name='Austen']");



ToString()

Description

Converts an XML Document object to its equivalent string representation

Return Type : string

Static : No

Namespace : XmlLib.XmlDocument

Syntax

XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString("bookstore");
string bookStoreString = xmlDocument.ToString();
ShowMessage("I just converted the XML Document and the result is: " + bookStoreString);



Encrypt(string)

Description

Encrypts the XmlDocument using the certificate found in a specified path.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlDocument

Parameters

Name Data Type Description
CertificatePath string Path of the certificate file

Syntax

string certificatePath = "path/to/certificate";
XmlLib.XmlDocument doc;
XmlLib.XmlElement elem = doc.Encrypt(certificatePath);



Encrypt(string, string)

Description

Encrypts the XmlDocument using a password-protected certificate found in a specified path.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlDocument

Parameters

Name Data Type Description
CertificatePath string Path of the certificate file
CertificatePassword string Password of the certificate file

Syntax

string certificatePath = "path/to/certificate";
string password = "pass123";
XmlLib.XmlDocument doc;
XmlLib.XmlElement elem = doc.Encrypt(certificatePath, password);



XmlElement


Description

Represents an XML Element (Object, representing the data between the element's start tag and the element's end tag.)

Properties

Name Data Type Static Readonly Description
InnerText string No No Gets or sets the concatenated values of the node and all its children. Setting this property replaces all the children with the parsed contents of the given string.

Methods

GetAttribute(string)

Description

Returns the value of the XML attribute with the specified name.

Return Type : string

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
name string The name of the attribute to retrieve

Syntax

// <file type='gif' />
XmlLib.XmlElement elem;
string attr = elem.GetAttribute("type"); //attr = 'gif'



SetAttribute(string, string)

Description

Set the value of the XML attribute with the specified name.

Return Type : void

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
name string The name of the attribute to create or alter.
value string The value to set for the attribute.

Syntax

// <file type='gif' />
XmlLib.XmlElement elem;
string attr = elem.GetAttribute("type"); //attr = 'gif'
elem.SetAttribute("type", "jpg"); //now, <file type='jpg' />



SelectElement(string)

Description

Returns an XML Element object, based on a specified XPath Expression. If not exists, returns nothing.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
xpath string The XPath expression

Syntax

string xmlString = 
 "<employee>" +
 "  <firstname>Dwight</firstname>" +
 "  <lastname>Schrute</lastname>" +
 "  <occupation>" +
 "    <title>Assistand TO the Regional Manager</title>" +
 "    <title>Beet Farmer</title>" +
 "  </occupation>" +
 "</employee>";
XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString(xmlString);
XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation");
= occupation.SelectElement("/title[1]");



SelectElements(string)

Description

Select a list of Elements matching the XPath expression

Return Type : Collection

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
xpath string The XPath expression

Syntax

string xmlString = 
 "<employee>" +
 "  <firstname>Dwight</firstname>" +
 "  <lastname>Schrute</lastname>" +
 "  <occupation>" +
 "    <title>Assistand TO the Regional Manager</title>" +
 "    <title>Beet Farmer</title>" +
 "  </occupation>" +
 "</employee>";
XmlLib.XmlDocument xmlDocument;
xmlDocument.LoadFromString(xmlString);
XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation");
ment] titles = occupation.SelectElements("/title");



ToString()

Description

Converts an XML Element to its equivalent string representation

Return Type : string

Static : No

Namespace : XmlLib.XmlElement

Syntax

XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation");
ShowMessage(occupation.ToString());



Encrypt(string)

Description

Encrypts the XML Element using the certificate found in a specified path.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
CertificatePath string Path of the certificate file

Syntax

XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation");
XmlLib.XmlElement encryptedOccupation = occupation.Enrypt("path/to/certificate");



Encrypt(string, string)

Description

Encrypts the XML Element using a password-protected certificate found in a specified path.

Return Type : XmlLib.XmlElement

Static : No

Namespace : XmlLib.XmlElement

Parameters

Name Data Type Description
CertificatePath string Path of the certificate file
CertificatePassword string Password of the certificate file

Syntax

XmlLib.XmlElement occupation = xmlDocument.SelectElement("/employee/occupation");
XmlLib.XmlElement encryptedOccupation = occupation.Enrypt("path/to/certificate", "pass123");