herolab.XPath: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 13: Line 13:
'''Parameters'''
'''Parameters'''
{{param|XPath|The XPath expression to evaluate against the XML statblock.}}
{{param|XPath|The XPath expression to evaluate against the XML statblock.}}
{{param|id|The id of the token. Defaults to the Current Token.}}{{TrustedParameter}}
{{param|id|The id of the token. Defaults to the Current Token.}}


Returns the requested data.
Returns the requested data.

Revision as of 21:56, 6 March 2019

herolab.XPath() Function

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

Introduced in version 1.5.0
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 various values from Hero Lab data (which is in XML).
[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:

Human Neutral Good 1

See Also