In this xml, i have to filter tag <controlTask> id values which matches to my stringArray $myStringArray (using powershell)
if matches, traverse into it and find <myflow:eventBooster> with event="start" and replace script content with $startContent1, and find event="end" replace with $endContent1
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:myflow="http://myflow.google.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="POC">
<thread id="JALSA_KUSHI_ONLY" name="JALSA ONLY" isFine="true" myflow:isOk="true">
<docprocess>My Doc Process</docprocess>
<extensionElements>
<myflow:historyLevel><![CDATA[audit]]></myflow:historyLevel>
</extensionElements>
<controlTask id="ReadDoc1" name="Read Doc" myflow:type="http">
<extensionElements>
<myflow:field name="rnhAsJson">
<myflow:string><![CDATA[true]]></myflow:string>
</myflow:field>
<myflow:eventBooster event="start" class="org.abc.SecureJavascripteventBooster">
<myflow:scriptInfo scriptType="javascript" script=""use strict";var loaded={require:require,exports:{}};" />
</myflow:eventBooster>
<myflow:eventBooster event="end" class="org.abc.SecureJavascripteventBooster">
<myflow:scriptInfo scriptType="javascript" script=""use strict";var loaded={require:require,exports:{}},pending={};function require(e,t){define(void 0,e,t)};" />
<myflow:field name="language">
<myflow:string><![CDATA[javascript]]></myflow:string>
</myflow:field>
</myflow:eventBooster>
</extensionElements>
</controlTask>
<JimmyGate id="MyWish" name="My own" />
<controlTask id="WriteDoc1" name="write task" myflow:type="http">
<extensionElements>
<myflow:field name="requestMethod">
<myflow:string><![CDATA[POST]]></myflow:string>
</myflow:field>
<myflow:eventBooster event="start" class="org.abc.SecureJavascripteventBooster">
<myflow:scriptInfo scriptType="javascript" script=""use strict";" />
</myflow:eventBooster>
<myflow:eventBooster event="end" class="org.abc.SecureJavascripteventBooster">
<myflow:scriptInfo scriptType="javascript" script=""use strict";var loaded={require:require}" />
</myflow:eventBooster>
</extensionElements>
</controlTask>
<JimmyGate id="sid-iquweiq-1uy1-8173eu-817e81ye" />
</thread>
</definitions>
I have controltaskId, but unable to traverse into it. But getting all the data matching with <controlTask>, <myflow:eventBooster>
$xmldata =( Select-Xml -Path $location\xyz.xml -XPath / ).Node;
$controltaskId = $xmldata.definitions.thread.controlTask.GetAttribute("id");
can someone please help here
$xmldata.definitions.thread.controlTaskresolves to an array of both<controlTask>nodes. You'll want to do something likeforeach($controlTaskNode in $xmldata.definitions.thread.controlTask){ "This particular controlTask node has id '$($controlTaskNode.GetAttribute('id'))'"}