Skip to content

herolab.XPath

Jamz edited this page Mar 5, 2019 · 3 revisions
• Introduced in version 1.5.0

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.

*Note: This evaluates directly against the stored XML statblock data on the token so you do not need to first retrieve and store the XML in a variable.

Usage

  1. herolab.XPath(XPath)
  2. herolab.XPath(XPath, id)

Parameters

  1. XPath - The XPath expression to evaluate against the XML statblock.
  2. id - The token id of the token to name, defaults to the Current Token.

Example

  1. [race = herolab.XPath('/document/public/character/race/@name')]
  2. [alignment = herolab.XPath('/document/public/character/alignment/@name')]
  3. [improvedInit = herolab.XPath('boolean(/document/public/character/feats/feat[starts-with(@name,"Improved Initiative")])')]

sample

<?xml version="1.0" encoding="UTF-8" standalone="no"?><document>
  <public>
    <program name="Hero Lab" url="http://www.wolflair.com">
      <programinfo>Hero Lab and the Hero Lab logo are Registered Trademarks of LWD Technology, Inc. Free download at http://www.wolflair.com Pathfinder® and associated marks and logos are trademarks of Paizo Inc.®, and are used under license.</programinfo>
      <version build="743" primary="8" secondary="4" tertiary="b" version="8.4b"/>
    </program>
    <localization language="eng" units="imperial"/>
    <character characterindex="1" name="Drexel Spevak + New Eidolon" nature="normal" playername="" relationship="ally" role="pc" type="Hero">
    <race ethnicity="" name="rakshasa-spawn tiefling" racetext="rakshasa-spawn tiefling"/>
    <alignment name="Neutral Good"/>
    <templates summary=""/>
    <size name="Medium">
...