herolab.XPath

From RPTools Wiki
Revision as of 18:46, 5 March 2019 by Phergus (talk | contribs) (Created page with "{{MacroFunction |name=herolab.XPath |trusted=true |version=1.5 |description= This function returns data results based on the passed in XPath expression from the XML statblock....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

It will return a 1 if successful, otherwise it will return a 0.

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.