• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

XPath Modding Explanation Thread

This is a large amount of information in these posts. I'll be working on a full, properly formed tutorial as we get access to A17 and we can really make the xpath system shine. I've listed some examples here, and we'll be posting a ton more xpath samples over the coming weeks, as we port the SDX modlets over to use the native hooks.

By all means, begin posting your comments, questions, or requests for clarity.

Since we now know that xpath support will be built-into the vanilla base game, and discussions earlier were getting a bit confusing, I've decided to make a new thread to try to demystify xpath and what it'll mean for mods and modders going forward in A17. The information in this thread has been pieced together from forum and discord discussions. They may not be 100% accurate, but I will update this thread when we know the full implementation.

XPath is a way of adding, changing, or removing XML lines and nodes, without directly editing the XML files. It allows you to apply patches to the XML files without manually editing the vanilla XML files.

SDX has had partial support for this since its initial release, and a lot of the SDX Modlets are already written this way. We will be using some of the SDX's xpath as examples in this thread, but SDX is not required to do this in A17 and onwards.

I believe in using examples to explain concept, so in the next few posts, you'll see a mixture of explanation, along with sample xpath code.

The following Mod structure is expected for A17 and beyond:

Code:
Mods/
   <ModName>/
       Config/
       UIAtlases/ItemIconAtlas/
       ModInfo.xml

   <ModName2>/
       Config/
       ModInfo.xml
You will be able to have multiple mods loaded, and loading will occur as long as the ModInfo.xml exists. This is unchanged from what we've been doing doing with other alphas, with the exception of the Config folder.

This Config folder will support loading XML files, written using xpath, in the following folder structure:

Code:
Config/entityclasses.xml
Config/gamestages.xml
Config/items.xml
The files in the Config folder will not be a full copy of the vanilla file with your changes. Rather, it'll contain the changes you want done to the vanilla files. The files under the Config must match the vanilla file name. You cannot create an entityclasses2.xml file, and expect it to work. Any changes in the entityclasses.xml will have to be done in the same file. However, each mod can have its own entityclasses.xml.

During the game's initialization, it will perform the xpath merge in-memory only; no files will be actually be modified. This would allow us to remove mods we no longer want, without re-validating against steam, or previous copies of the xml. That's a big one. No more half merging of a mod, and not having it work, then trying to pull it back out.

What this means for us is that we'll be able to make a variety of smaller mods, which I've been calling modlets, which can add, remove and change smaller pieces of the game. They can be used together, or they could be added to an overhaul mod, in order to style your game play easier.

These modlets would also exists outside of the Data/Config folder, so if you have made direct XML changes in your Alpha 17.1 Data/Config files, and Steam updated the game to 17.2, you would have lost your changes, or would have to re-merge them in. We've all been there before. But if they existed as modlets, under the Mods folder, they would be safe. And as long as your xpath is still valid to the new XML, it should load up with no additional work on your part.

If we could use xyth's JunkItems modlet, which adds random, scrappable junk items to loot containers, and add them to Valmod Overhaul. Likewise, if Valmod Overhaul did not have the No Ammo modlet (which gives you the ability to unload a gun and get its bullets back without disassembling it), you could drop the NoAmmo modlet into your Mods folder. Headshots only? Want to increase stack sizes? Same deal.

With a properly constructed modlet, we'll be able to piece together new play styles for people to enjoy and share. A modder working on a large overhaul won't have to duplicate work. If they wanted to include the No Ammo mod, they wouldn't have to code it themselves, letting them focus on the bits that make their mod really unique.

Let's get started on your journey...

 
Last edited by a moderator:
Is there a way to remove/set/insertafter/etc ALL matching lines?

For example, if I wanted to remove all of the AITasks and AITargets from say the animalWolf entity_class, I tried:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
However, this is failing to remove all the entries. I also played a bit with it and found this didn't work either:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-*']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-*']"/>
When I specify every single line, it works fine:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-2']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-3']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-4']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-5']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-6']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-7']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-8']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-1']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-2']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-3']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-4']"/>
I assume the issue is only one of the entries is being removed, so I'd have to do the following to do the same thing with starts-with:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
Any way to prevent such repetition? I searched this thread and didn't find any examples of manipulating multiple instances with a single xpath line. Thanks in advance!

- - - Updated - - -

Xpath gets applied when the game and worlds load. Seeing what the final XML looks like can help figure out when things don't go right. However, it'll only be useful if your changes were not fatal to the XML parsing.
Oh it gives you the final modified xml file, that is indeed useful! Should you edit your original 1st post to add that suggestion? Either way thanks for the explanation! :3

 
Is there a way to remove/set/insertafter/etc ALL matching lines?
For example, if I wanted to remove all of the AITasks and AITargets from say the animalWolf entity_class, I tried:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
However, this is failing to remove all the entries. I also played a bit with it and found this didn't work either:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-*']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-*']"/>
When I specify every single line, it works fine:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-2']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-3']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-4']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-5']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-6']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-7']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITask-8']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-1']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-2']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-3']"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[@name='AITarget-4']"/>
I assume the issue is only one of the entries is being removed, so I'd have to do the following to do the same thing with starts-with:

Code:
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
<remove xpath="/entity_classes/entity_class[@name='animalWolf']/property[starts-with(@name, 'AITa')]"/>
Any way to prevent such repetition? I searched this thread and didn't find any examples of manipulating multiple instances with a single xpath line. Thanks in advance!

- - - Updated - - -

Oh it gives you the final modified xml file, that is indeed useful! Should you edit your original 1st post to add that suggestion? Either way thanks for the explanation! :3
What about /property[contains(@name, 'AITa')] ?

 
What about /property[contains(@name, 'AITa')] ?
Yep, same thing, it's correctly matching it, just only removing the first instance it encounters before stopping.

Code:
	<!--Element removed by: "Friendly Animals"-->
<property name="AITask-2" value="BreakBlock" />
<property name="AITask-3" value="Territorial" />
<property name="AITask-4" value="ApproachAndAttackTarget" param1="EntityAnimalStag,40,EntityPlayer,15,EntityZombie,30" />
<property name="AITask-5" value="ApproachSpot" />
<property name="AITask-6" value="Look" />
<property name="AITask-7" value="Wander" />
<property name="AITask-8" value="" />
<property name="AITarget-1" value="SetAsTargetIfHurt" />
<property name="AITarget-2" value="BlockingTargetTask" />
<property name="AITarget-3" value="SetNearestEntityAsTarget" param1="EntityPlayer,8,EntityAnimalStag,0,EntityZombie,0" />
<property name="AITarget-4" value="" />
Searched around on the net but couldn't find a solution for manipulating multiple nodes using a single xpath command. Oh well, for now I'll just have to have multiple entries!

 
I want to increase the number of eggs that drop, but I keep getting errors with my xpath.

I want to change this

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1" prob="0.25"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

to

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1,2" prob="0.30"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

Here is my xml:

<configs>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/count">1,2</set>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/prob">0.30</set>

</configs>

Can you tell me what I'm doing wrong here?

 
I want to increase the number of eggs that drop, but I keep getting errors with my xpath.
I want to change this

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1" prob="0.25"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

to

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1,2" prob="0.30"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

Here is my xml:

<configs>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/count">1,2</set>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/prob">0.30</set>

</configs>

Can you tell me what I'm doing wrong here?
Untested but you might try

Code:
<set xpath="/lootcontainers/lootcontainer[@id='25']/item[@name='foodEgg']/@count">1,2</set>
<set xpath="/lootcontainers/lootcontainer[@id='25']/item[@name='foodEgg']/@prob">0.30</set>
 
I want to increase the number of eggs that drop, but I keep getting errors with my xpath.
I want to change this

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1" prob="0.25"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

to

<!-- birds nest-->

<lootcontainer id="25" count="1,3" size="4,3" sound_open="UseActions/open_garbage" sound_close="UseActions/close_garbage" loot_quality_template="baseTemplate">

<item name="foodEgg" count="1,2" prob="0.30"/>

<item name="resourceFeather" count="4,8" prob="0.75"/>

</lootcontainer>

Here is my xml:

<configs>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/count">1,2</set>

<set xpath="/lootcontainers/lootcontainer[@id=25]/[@loot_quality_template=baseTemplate]/[@name=foodEgg]/prob">0.30</set>

</configs>

Can you tell me what I'm doing wrong here?
You are close.

I don't think you need to evaluate the loot_quality_template at all, and you were missing the /item/, which takes it inside each loot container to the change you want.

Code:
<configs>
<set xpath="/lootcontainers/lootcontainer[@id='25' ]/item[@name='foodEgg']/@count">1,2</set>
<set xpath="/lootcontainers/lootcontainer[@id='25' ]/item[@name='foodEgg']/@prob">0.3</set>
</configs>
[/CODE]
 
Searched around on the net but couldn't find a solution for manipulating multiple nodes using a single xpath command. Oh well, for now I'll just have to have multiple entries!
"Append" works for multiple nodes, like this works:

Code:
    <append xpath="/entity_classes/entity_class[starts-with(@name, 'zombie')]">
So it seems to be at just, or at least, the "remove" command that doesn't work with multiple nodes.

 
Can you use more than two 'or' conditions? eg.

[@name=zombieJoeFeral' or @name='zombieBoeFeral' or @name='zombieYoFeral]

I'm thinking this would be the most efficient because I can't just use startswith + endswith as there are a bunch of Ferals with different health.

Edit: And I don't think I can just use [@name=HealthMax][@value=X] because that is in the effect_group and this needs to be placed outside the effect group.

 
Last edited by a moderator:
Actually...is there a way to search for something in the effect_group to determine location, but place it one node back by returning to the parent node? Such as use "/entity_classes/entity_class/effect_group/passive_effect[@name=HealthMax][@value=225]" to locate the proper location

Code:
<effect_group name="Base Effects">
<passive_effect name="HealthMax" operation="base_set" value="225"/>
<passive_effect name="HealthMax" operation="perc_set" value="1"/> <!-- Zombie HP scale -->
</effect_group>
But place the new line as such

Code:
[color="#DAA520"]<property name="DismemberMultiplierHead" value=".15"/>[/color]
<effect_group name="Base Effects">
<passive_effect name="HealthMax" operation="base_set" value="225"/>
<passive_effect name="HealthMax" operation="perc_set" value="1"/> <!-- Zombie HP scale -->
</effect_group>
Would something like this work?

Code:
<append xpath="/entity_classes/entity_class/effect_group/passive_effect[@name='HealthMax'][@value='225']/../..">
<property name="DismemberMultiplierHead" value=".15"/>
</append>
 
Last edited by a moderator:
Nm, I just decided to test it myself and it works :D . At least that info is there if someone is looking for it.
SandyBeaches did comment right after your question, unless it was just 2 ppl posting at once.

And ty, cuz this is half of what I came here for

---

So I'm trying to increase the stack sizes on feathers and Arrows/Bolts NOT including flaming/exploding

I copy pasted the drinkJar from one of the earlier posts as ref, and confirmed it works for the drinkJar items but not the ammo. I even copy/pasted the drinkJar and changed it to the ammoArrow/ammoCrossbow and Flaming/Exploding. Is it because ammoArrowFlaming/ammoCrossbowBoltExploding extend another item instead of being a parent item themselves? And if so, how would I fix it, with an <append> to those specific ones adding their own stack size variable?

Code:
<set xpath="/items/item[@name='resourceFeather']/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoArrow') and not(contains(@name, 'Flaming'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoCross') and not(contains(@name, 'Exploding'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'drinkJar') and not(contains(@name, 'Empty'))]/property[@name='Stacknumber']/@value">64</set>
 
Last edited by a moderator:
SandyBeaches did comment right after your question, unless it was just 2 ppl posting at once.
And ty, cuz this is half of what I came here for

---

So I'm trying to increase the stack sizes on feathers and Arrows/Bolts NOT including flaming/exploding

I copy pasted the drinkJar from one of the earlier posts as ref, and confirmed it works for the drinkJar items but not the ammo. I even copy/pasted the drinkJar and changed it to the ammoArrow/ammoCrossbow and Flaming/Exploding. Is it because ammoArrowFlaming/ammoCrossbowBoltExploding extend another item instead of being a parent item themselves? And if so, how would I fix it, with an <append> to those specific ones adding their own stack size variable?

Code:
<set xpath="/items/item[@name='resourceFeather']/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoArrow') and not(contains(@name, 'Flaming'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoCross') and not(contains(@name, 'Exploding'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'drinkJar') and not(contains(@name, 'Empty'))]/property[@name='Stacknumber']/@value">64</set>
If an extended item does not have stacknumber, then you'd have to do an append to it, rather than doing a set.

Code:
<append xpath="//" >
   <property name="Stacknumber" value="6" />
</append>
 
If an extended item does not have stacknumber, then you'd have to do an append to it, rather than doing a set.
Code:
<append xpath="//" >
   <property name="Stacknumber" value="6" />
</append>
Thx sphereii I'll see about appending a stack number in the append section (the sets are beneath the appends for that specific reason)

---

Ok so the whole thing currently looks like this

Code:
<configs>
   <append xpath="/items">
<!-- snip -->
   </append>
<append xpath="/items/item[@name='ammoArrowFlaming' or @name='ammoCrossbowBoltExploding']/property[@name='Stacknumber']/@value">250</append>
<set xpath="/items/item[@name='resourceCement' or @name='resourceConcreteMix']/property[@name='Stacknumber']/@value">6000</set>
<set xpath="/items/item[@name='resourceFeather']/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoArrow') and not(contains(@name, 'Flaming'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoCross') and not(contains(@name, 'Exploding'))]/property[@name='Stacknumber']/@value">500</set>
</configs>
I have also tried separating into 2 separate <append>(s) but I get the same result, but there are no parsing errors and the other parts of the mod work just fine

Code:
<append xpath="/items/item[@name='ammoArrowFlaming']/property[@name='Stacknumber']/@value">250</append>
<append xpath="/items/item[@name='ammoCrossbowBoltExploding']/property[@name='Stacknumber']/@value">250</append>
 
Last edited by a moderator:
Thx sphereii I'll see about appending a stack number in the append section (the sets are beneath the appends for that specific reason)
---

Ok so the whole thing currently looks like this

Code:
<configs>
   <append xpath="/items">
<!-- snip -->
   </append>
<append xpath="/items/item[@name='ammoArrowFlaming' or @name='ammoCrossbowBoltExploding']/property[@name='Stacknumber']/@value">250</append>
<set xpath="/items/item[@name='resourceCement' or @name='resourceConcreteMix']/property[@name='Stacknumber']/@value">6000</set>
<set xpath="/items/item[@name='resourceFeather']/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoArrow') and not(contains(@name, 'Flaming'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoCross') and not(contains(@name, 'Exploding'))]/property[@name='Stacknumber']/@value">500</set>
</configs>
I have also tried separating into 2 separate <append>(s) but I get the same result, but there are no parsing errors and the other parts of the mod work just fine

Code:
<append xpath="/items/item[@name='ammoArrowFlaming']/property[@name='Stacknumber']/@value">250</append>
<append xpath="/items/item[@name='ammoCrossbowBoltExploding']/property[@name='Stacknumber']/@value">250</append>
Use exportcurrentconfigs in the console to export how all the xml files look after they've been modified by your xpath. Can help to debug!

Can you post the before and after of what code you're trying to modify, from what to what?

 
Is there a way to set a value to an empty string? Throws a null exception when I try the xpath set.

Have worked around it by removing the tag and adding it back.

Code:
<configs>
 <!-- Remove chainsaw and auger looping sounds -->
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_start']"/>
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_repeat']"/>
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_end']"/>
 <append xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']">
   <property name="Sound_start" value=""/>
 </append>

 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_start']"/>
 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_repeat']"/>
 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_end']"/>
 <append xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']">
   <property name="Sound_start" value=""/>
 </append>

</configs>
 
Use exportcurrentconfigs in the console to export how all the xml files look after they've been modified by your xpath. Can help to debug!
Can you post the before and after of what code you're trying to modify, from what to what?
Pastebin complained my file was too big, so I'll separate it

STABLE LAUNCH (but limiting stack size on Flaming Arrow & Exploding Xbow not working):

items.xml from my mod test folder:

https://pastebin.com/Ybrhajdr

items.xml from exportcurrentconfigs (starting from last vanilla item):

https://pastebin.com/6jj1qcSM

changed item from items.xml from exportcurrentconfigs:

https://pastebin.com/gq8nTy4Y

If I change the items.xml in the mod test folder to:

Code:
<configs>
<!-- LAZY COPY/PASTE TEMPLATES -->
<!-- <property name="" value=""/> -->
   <append xpath="/items">
<!-- snip -->
</append>
<append xpath="/items/item[@name='ammoArrowFlaming']><property name="Stacknumber" value="250"/></append>
<append xpath="/items/item[@name='ammoCrossbowBoltExploding']><property name="Stacknumber" value="250"/></append>
<set xpath="/items/item[@name='resourceCement' or @name='resourceConcreteMix']/property[@name='Stacknumber']/@value">6000</set>
<set xpath="/items/item[@name='resourceFeather']/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoArrow') and not(contains(@name, 'Flaming'))]/property[@name='Stacknumber']/@value">500</set>
<set xpath="/items/item[starts-with(@name, 'ammoCross') and not(contains(@name, 'Exploding'))]/property[@name='Stacknumber']/@value">500</set>
</configs>
I get the error in console:

ERR Failed loading and parsing XML (items.xml)

XmlException: attribute values cannot contain '<' Line 95, position 55.

ERR XML Loader. Patching 'items.xml' from mod 'test' failed.

NullReferenceException: Object reference not set to an instance of an Object.

Sorry for slow response, I keep trying and learning new ways to not do what I want.

 
Is there a way to set a value to an empty string? Throws a null exception when I try the xpath set.
Have worked around it by removing the tag and adding it back.

Code:
<configs>
 <!-- Remove chainsaw and auger looping sounds -->
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_start']"/>
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_repeat']"/>
 <remove xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']/property[@name='Sound_end']"/>
 <append xpath="/items/item[@name='meleeToolChainsaw']/property[@class='Action0']">
   <property name="Sound_start" value=""/>
 </append>

 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_start']"/>
 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_repeat']"/>
 <remove xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']/property[@name='Sound_end']"/>
 <append xpath="/items/item[@name='meleeToolAuger']/property[@class='Action0']">
   <property name="Sound_start" value=""/>
 </append>

</configs>
Not sure how to do it with XPath but are you trying to fix the looping idle sound or just make them silent? If just trying to fix the idle bug you can comment out the idle sounds on each (tested on local files and on a server's XML but not local in b199 and it was a temp fix for the looping when not equipped but), still plays the sound when using them.

 
Is there a way to set a value to an empty string? Throws a null exception when I try the xpath set.
Have worked around it by removing the tag and adding it back.
Since we just got setattribute, I'm hoping that there will be a removeattribute in the near future. I was afraid that omitting the value would cause an exception in the current implementation.

 
Back
Top