herolab.XPath: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 2: | Line 2: | ||
|name=herolab.XPath | |name=herolab.XPath | ||
|trusted=true | |trusted=true | ||
|version=1.5 | |version=1.5.0 | ||
|description= | |description= | ||
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= | |usage= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
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.}} | {{param|id|The id of the token. Defaults to the Current Token.}}{{TrustedParameter}} | ||
Returns the requested data. | Returns the requested data. | ||
|example= | |example= | ||
Get | Get various values from Hero Lab data (which is in XML). | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[race = herolab.XPath('/document/public/character/race/@name')] | [race = herolab.XPath('/document/public/character/race/@name')] | ||
Line 25: | Line 25: | ||
</source> | </source> | ||
Returns: | Returns: | ||
<source lang="mtmacro" | <source lang="mtmacro"> | ||
Human Neutral Good 1 | |||
</source> | </source> | ||
|also= | |also= | ||
[[Hero Lab Integration|Hero Lab Integration]] | [[Hero Lab Integration|Hero Lab Integration]] | ||
}} | }} | ||
[[Category:Hero Lab Function]] | [[Category:Hero Lab Function]] |
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.Note: This parameter can only be used in a Trusted Macro.
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