Trying to set multiple property values in xml using xpath

Viewed 44

Starting off, I am trying to adjust a mod I created for a game (7 Days To Die) I don't really have a lot of experience with XML modification. But I got it to do what I wanted.

However I don't want to run through EVERY item in the list to have to adjust the values of items.

Example of the XML file:

<?xml version="1.0" encoding="UTF-8"?>
<items>
<item name="ammo9mmBulletBall">
    <property name="Tags" value="ammo"/>
    <property name="DisplayType" value="ammoBullet"/>
    <property name="HoldType" value="45"/>
    <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
    <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
    <property name="Material" value="Mbrass"/>
    <property name="MeltTimePerUnit" value=".4"/>
    <property name="Stacknumber" value="300"/> <!-- STK ammo high -->
    <property name="EconomicValue" value="9"/>
    <property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"/>
    <effect_group name="ammo9mmBulletBall" tiered="false">
        <passive_effect name="EntityDamage" operation="base_set" value="32" tags="perkGunslinger,9mmGun"/>
        <passive_effect name="BlockDamage" operation="base_set" value="6" tags="perkGunslinger"/>
        <passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
        <passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/>
    </effect_group>
</item>
</items>

Example off the mod file:

<?xml version="1.0" encoding="utf-8"?>
<configs>
<!-- * * * * * * * * * * ammunition / arrows / bolts / fuel * * * * * * * * * * -->
<set xpath="/items/item[starts-with(@name, 'ammo')]/property[@name='Stacknumber']/@value">500</set>

My problem is, there are other items in the XML document that start with "ammo" that I do not want to change.

I have attempted to find info on having an exception in the xpath, so something like:

<set xpath="/items/item[starts-with(@name, 'ammo'[not(@name, 'ammoBundle')])]/property[@name='Stacknumber']/@value">500</set>

However that obviously didn't work. Is there a way to do this? Or am I going to have to stick to doing each value edit manually?

Another alternative I looked into, was if it was a part of the Group "Ammo/Weapons,Ammo,Ranged Weapons" But I could not find information on that either.

If anyone could help me, that would be great.

Edit: I was able to achieve a portion of what I am after with:

<set xpath="/items/item[starts-with(@name, 'ammo') and not(contains(@name, 'Bundle'))]/property[@name='Stacknumber']/@value">500</set>

However I am still trying to change a property value based on the the item(s) found using the above, by the property value already set: <property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons" So if the items have the property value listed above, they will adjust their 'Stacknumber' property value. Unsure if that is possible.

Edit: Further examples So this is just the items themselves, no properties for each line.

Example of what I want to include
<item name="ammo9mmBulletBall">
<item name="ammo9mmBulletHP">
<item name="ammo9mmBulletAP">
<item name="ammo44MagnumBulletBall">
<item name="ammo44MagnumBulletHP">
<item name="ammo44MagnumBulletAP">
<item name="ammoDartIron">
<item name="ammoShotgunBreachingSlug">


Example of what I want to exclude
<item name="ammoJunkTurretRegular">
<item name="ammoJunkTurretShell">
<item name="ammoJunkTurretAP">
<item name="ammoBundleMaster">
<item name="ammoBundleJunkTurretRegular">
<item name="ammoBundleJunkTurretShell">
<item name="ammoGasCanBundle">
<item name="ammoArrowFlamingSchematic">
<item name="ammoCrossbowBoltExplodingSchematic">
<item name="ammoGasCanSchematic">
<item name="ammoProjectileZombieVomit">
1 Answers

If you only want to modify the item whose @name is "ammo9mmBulletBall" then use item[@name='ammo9mmBulletBall'] rather than item[starts-with(@name, 'ammo')]

Related