herolab.XPath: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(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....")
 
No edit summary
Line 15: Line 15:
{{param|id|The id of the token. Defaults to the Current Token.}}
{{param|id|The id of the token. Defaults to the Current Token.}}


It will return a 1 if successful, otherwise it will return a 0.
Returns the requested data.


|example=
|example=

Revision as of 18:47, 5 March 2019

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.