I have a problem with XPATH, though not for modding purposes, and remembered there was knowledge about it here.
I'm trying to use a tool called xmlstarlet to output the information I need from an XML file. I've gotten far it feels, but the last pieces are missing and the filtering/if-test doesn't work. Are any of you familiar with this tool and syntax? Searching fails me :-(
The general structure is:
redxml/definitions/loot_definitions/loot/loot_entry
redxml/definitions/loot_definitions/loot/loot_entry/@name
redxml/definitions/loot_definitions/loot/loot_entry/@player_level_min
redxml/definitions/loot_definitions/loot/loot_entry/@player_level_max
redxml/definitions/loot_definitions/loot/loot_entry/@quantity_min
redxml/definitions/loot_definitions/loot/loot_entry/@quantity_max
redxml/definitions/loot_definitions/loot/loot_entry/@chance
redxml/definitions/loot_definitions/loot/loot_entry/@respawn_time
With the relevant piece of XML such as this:
<loot name="_monster__Wildhunt minion" player_level_min="0" player_level_max="0" quantity_min="0" quantity_max="2" chance="-1" >
<loot_entry name="Sulfur" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="50" respawn_time="0" />
<loot_entry name="Rotten meat" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="26" respawn_time="0" />
<loot_entry name="Monstrous brain" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="6" respawn_time="0" />
<loot_entry name="Monstrous blood" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="6" respawn_time="0" />
<loot_entry name="Monstrous bone" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="6" respawn_time="0" />
<loot_entry name="Monstrous saliva" player_level_min="0" player_level_max="0" quantity_min="1" quantity_max="1" chance="6" respawn_time="0" />
</loot>
What I want to do is to extract all the monster types that drop a particular type of loot, in this case "Sulfur".
I have tried this command, which just ends up listing all the monster types in the file, instead of applying the if-test and listing the monsters that apply.
xmlstarlet sel -t -v "//redxml/definitions/loot_definitions/loot/@name" -i "//redxml/definitions/loot_definitions/loot/loot_entry[@name='Sulfur']" -nl def_loot_monsters.xml
There is documentation about the tool here, but I'm clearly still doing something wrong:
http://xmlstar.sourceforge.net/doc/UG/ch04s01.htmlIf you are able to help, please offer a hand
