Search code examples
xmlwindowsxpathxmlstarletquoting

What is wrong with my xmlstarlet update command?


I am trying to edit an element's value in an xml file using xmlstarlet but the edit has no effect. No errors are displayed nor any success message.

I have tested my xpath query using an online xpath tester.

This is my xml file:

<workflow scriptid="customworkflow_sktest01">
  <runasadmin>F</runasadmin>
  <workflowstates>
    <workflowstate scriptid="workflowstate15154">
      <description></description>
      <workflowactions triggertype="ONENTRY">
        <setfieldvalueaction scriptid="workflowaction88038">
          <valuejoinfield></valuejoinfield>
          <valueselect>24506</valueselect>
          <valuetext></valuetext>
        </setfieldvalueaction>
      </workflowactions>
    </workflowstate>
  </workflowstates>
</workflow>

This is the command I'm using with xmlstarlet:

C:\...\xmlstarlet-1.6.1-win32\xmlstarlet-1.6.1>xml edit -P --update "/workflow/workflowstates/workflowstate/workflowactions/setfieldvalueaction[@scriptid="workflowaction88038"]/valueselect" -v 1234 "C:\...\customworkflow_sktest01.xml"

When I run that command xmlstarlet simply echoes the unmodified source xml.

Solution Update:

The following is the working command:

C:\...\xmlstarlet-1.6.1-win32\xmlstarlet-1.6.1>xml edit -P --update "/workflow/workflowstates/workflowstate/workflowactions/setfieldvalueaction[@scriptid='workflowaction88038']/valueselect" -v 1234 "C:\...\customworkflow_sktest01.xml"

Solution

  • I suggest to replace

    "workflowaction88038"
    

    by

    'workflowaction88038'