Einhugur Xml Plugin for Xojo |

# EinhugurXml.XPathVariableSet Class (console safe)

Class to create set of variables for parameterized XPath queries.
XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.
Variable references have the form $name; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to XPathQuery constructor or to EinhugurXml.Node.SelectNodes/EinhugurXml.Node.SelectNode functions.

Object
XPathVariableSet

class EinhugurXml.XPathVariableSet

#### Constructors

XPathVariableSet | Constructor which takes no parameters.

#### Methods

Add | Adds a variable to the set.
Set | Sets value of named Boolean variable.
Set | Sets value of named Double variable.
Set | Sets value of named XPathNodeSet variable.
Set | Sets value of named string variable.

#### Examples

Example:
// In this example we will use Pre-compiled parameterized
// XPath query to select nodes.
// --------------------------------------------------------
var f as FolderItem = SpecialFolder.Resources.Child("xgconsole.xml")
if not f.Exists then
MessageBox("Could not find file xgconsole.xml")
return
end if
// Select nodes via compiled query
using EinhugurXml
// Most parts of the plugin do not Throw exceptions, but Loading XML
// document does as well as all XPath query functionality.
try
var document as Document = Document.FromFile(f)
var vars as new XPathVariableSet()
vars.Add("remote", XPathType.TYPE_BOOLEAN)
// We compile the query once
var queryRemoteTools as new XPathQuery("/Profile/Tools/Tool[@AllowRemote = string($remote)]", vars)
// WE then execute the query twice, with different parameter
vars.Set("remote", true)
var toolsRemote as XPathNodeSet = queryRemoteTools.EvaluateNodeSet(document)
vars.Set("remote", false)
var toolsLocal as XPathNodeSet = queryRemoteTools.EvaluateNodeSet(document)
ListBox1.RemoveAllRows()
ListBox1.AddRow("---Tools Remote:---")
for each node as XPathNode in toolsRemote.XPathNodes
// XPathNode can contain either Node or Attribute depending on the query.
ListBox1.AddRow(node.Node.Name + ": " + node.Node.Attribute("Filename").AsString())
next
ListBox1.AddRow("---Tools Local:---")
for each node as XPathNode in toolsLocal.XPathNodes
// XPathNode can contain either Node or Attribute depending on the query.
ListBox1.AddRow(node.Node.Name + ": " + node.Node.Attribute("Filename").AsString())
next
catch ex as EinhugurXmlParserException
MessageBox(ex.Message + " - Offset:" + ex.Offset.ToString())
catch ex as EinhugurXPathException
MessageBox(ex.Message + " - Offset:" + ex.Offset.ToString())
end try

#### Supported Platforms:

- macOS Intel 64 bit
- macOS Apple Silicon
- Windows 32 bit
- Windows 64 bit
- Windows ARM 64 bit
- Linux 32 bit
- Linux 64 bit
- Linux ARM 32 bit
- Linux ARM 64 bit
- iOS