herolab.XPath

From RPTools Wiki
Revision as of 18:47, 5 March 2019 by Phergus (talk | contribs)
Jump to navigation Jump to search

herolab.XPath() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5
This function returns data results based on the passed in XPath expression from the XML statblock. This is a reliable and easier way to get stat data from a character than using regular expression parsing of Text stat blocks.

Usage

herolab.XPath(XPath)
herolab.XPath(XPath, id)

Parameters

  • XPath - The XPath expression to evaluate against the XML statblock.
  • id - The id of the token. Defaults to the Current Token.

Returns the requested data.

Example

Get the boolean value of the refresh flag in the Hero Lab data.
[race = herolab.XPath('/document/public/character/race/@name')]
[alignment = herolab.XPath('/document/public/character/alignment/@name')]
[improvedInit = herolab.XPath('boolean(/document/public/character/feats/feat[starts-with(@name,"Improved Initiative")])')]

Returns:

0 or 1

See Also

Version Changes

  • 1.5 - Added to main MapTool build.