How do I Use Source Values Window, Xpath Operators and Functions?

When adding a new xpath to the webstore configuration, you might need to do operations on values coming into that node. The following are some basic operators used under the “Select” section.

Note: Xpath is CASE SENSITIVE. It’s recommended to use “Xpath Scratch Pad” to create and test you xpaths. These are common operators and functions. See W3.org documentation on more functions: https://www.w3.org/TR/xpath/#namespace-nodes

If you are running into a problem with your webstore, please see our common list of webstore xpath configurations that might help.

Selecting All

“.” means to get all nodes under the given MATCH. Example below (using Xpath ScratchPad)

 

Browsing Nodes

This follows the same convention as browsing files. The statement below goes up the path and selects the “status” node.

Match: /array/value/billing_address

Select: ../status

 

Contains

Select any node under comment node that has the string “test”

match: /array/value/status_history/array
select: value[contains(comment,’test’)]/comment[text()]

 

Concatenation

match: /array/value/shipping_address

select: concat(firstname, ‘ ‘, lastname)

 

Division

node1 div node2 (value or node)

 

Multiplication

node1 * node2 (or value)

 

Subtraction

node1 – node2 (or value)

 

Addition

node1 + node2 (or value)

 

Acctivate Functions

If Statement

a:IIf(Expression as Boolean, TruePart as Object, FalsePart as Object) as Object

Inline If.  If Expression evalues to true, returns TruePart, otherwise FalsePart.

 

Concatenating name and email

a:ConcatNameAndEmail(FirstName as String, LastName as String, Email as String) as String
Concatenates first name, last name, and email together. Trims to fit Customer ID field.  E.g. “John Doe (john.doe@example.com)”

a:ConcatNameAndEmail(Name as String, Email as String) as String
Concatenates name and email.  Trims to fit Customer ID field. E.g. “John Doe (john.doe@example.com)”

 

Coalesce

a:StrCoalesce(Param1 as String, Param2 as String) as String
Returns the value of the first non-empty-string parameter.
a:StrCoalesce(Param1 as String, Param2 as String, Param3 as String) as String
Returns the value of the first non-empty-string parameter.

a:StrCoalesce(Param1 as String, Param2 as String, Param3 as String, Param4 as String) as String
Returns the value of the first non-empty-string parameter.

a:StrCoalesce(Param1 as String, Param2 as String, Param3 as String, Param4 as String, Param5 as String) as String
Returns the value of the first non-empty-string parameter.

Boolean String operations

a:StrEquals(Param1 as String, Param2 as String) as Boolean
Case-insensitive string comparison according to the system’s current language.

a:CBoolean(Value as String) as Boolean
Converts string to a boolean.  Defaults to false.

a:StrIsIn(Value as String, Param1 as String, Param2 as String) as Boolean
Case-insensitive string IsIn operator.

a:StrIsIn(Value as String, Param1 as String, Param2 as String, Param3 as String) as Boolean
Case-insensitive string IsIn operator.

a:StrIsIn(Value as String, Param1 as String, Param2 as String, Param3 as String, Param4 as String) as Boolean
Case-insensitive string IsIn operator.

a:StrIsIn(Value as String, Param1 as String, Param2 as String, Param3 as String, Param4 as String, Param5 as String) as Boolean
Case-insensitive string IsIn operator.

 

Replacing a current string with another

a:StrReplace(Value as String, ValueToFind as String, ValueToReplace as String) as Boolean
Case-insensitive string replacement function.

 

Changing letter case

a:ToLower(Value as String) as String
Converts text to lower case using the system’s current language.

a:ToUpper(Value as String) as String
Converts text to upper case using the system’s current language.

 

Convert to Xml

a:Xml(XmlString as String) as XPathNodeIterator
Converts strings to xml.

Trimming whitespace

a:LTrim(Value as String) as String
Trims whitespace on the left.

a:RTrim(Value as String) as String
Trims whitespace on the right.

a:Trim(Value as String) as String
Trims whitespace both left and right.

 

Tokenize strings

a:Split(Value as String, Delimiter as String) as XPathNodeIterator
Splits string.  Returns result in <Value> elements.

 

Line Operations

a:GetLine(Value as String, LineNumber as Int32) as String
Splits string by return characters and returns line.  Line Number is 1-based.

 

a:NewLine() as String
Adds a new New line.

 

String Delimiter

a:StrJoin(Values as XPathNodeIterator, Delimiter as String) as String
Converts node list into array of strings, and concatenates them into a string, inserting delimiter string between nodes.

For more information regarding XPaths, check out our docs page.