PatchOperationRemove targeting element with no attributes or children?

Started by Lockdown, May 29, 2019, 06:00:13 PM

Previous topic - Next topic

Lockdown

There is this def in vanilla:
  <DesignationCategoryDef>
    <defName>Structure</defName>
    <label>structure</label>
    <order>700</order>
    <specialDesignatorClasses>
      <li>Designator_Cancel</li>
      <li>Designator_Deconstruct</li>
      <li>Designator_RemoveBridge</li>
    </specialDesignatorClasses>
  </DesignationCategoryDef>


I want to remove just <li>Designator_RemoveBridge</li> from the specialDesignatorClasses. I've tried implementing the operation as such:

<Operation Class="PatchOperationRemove">
<xpath>*/DesignationCategoryDef[defName="Structure"]/specialDesignatorClasses[li="Designator_RemoveBridge"]</xpath>
</Operation>


But that removes the entire specialDesignatorClasses element, not just the specified <li>. How can I target just that li and leave its parent alone?

Kirby23590

I think you're missing something...

I think it was supposed to be like this...

<Operation Class="PatchOperationRemove">
<xpath>*/DesignationCategoryDef[defName="Structure"]/specialDesignatorClasses/[li[text() = "Designator_RemoveBridge"]</xpath>
</Operation>


I didn't test it out my self. I think that how it's supposed to go...

One "happy family" in the rims...
Custom font made by Marnador.



Mehni

Very close. You have an extra [ before li.

*/DesignationCategoryDef[defName="Structure"]/specialDesignatorClasses/li[text() = "Designator_RemoveBridge"]

Is correct.

Kirby23590

I C...

I just copied the code from Lockdown and didn't even see that "[" there...

At least we won't make the same mistake like that other one with that typo that's just hidden making the code freak out from that other time in the help forums... :P

One "happy family" in the rims...
Custom font made by Marnador.