У меня есть образец XML, как показано ниже:
<?xml version="1.0" encoding="utf-8"?>
<Searchable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" label="$RESX('Ebr.Crdm.Store.2_0','Item','Item')" xmlns="http://sysrepublic.com/Secure/4.0/DSL/SearchService">
<Fields>
<Field data-type="System.Int64" is-editable="true" id="item_transactionid" label="$RESX('Ebr.Crdm.Store.2_0','TransactionID','Transaction ID')" is-mandatory-display-field="false" is-hidden-display-field="false" is-virtual-date-time="false" is-display-field-only="false" use-utc-datetime="true" apply-user-timezone-offset="false" show-date="true" show-time="true" is-favourite="false" common-field="true">
<FieldDescription primary-key="false" nullable="false" readonly="false" hidden="true" format="text" enable-required-validation="true" />
<Operators>
<Operator name="equal" />
<Operator name="notequal" />
<Operator name="greaterthan" />
<Operator name="greaterthanequal" />
<Operator name="lessthan" />
<Operator name="lessthanequal" />
<Operator name="between" />
<Operator name="notbetween" />
<Operator name="in" />
<Operator name="notin" />
</Operators>
<LeftExpression>
<Field data-type="System.Int64" common-field="true">
<CollectionDescription collection="pos.CRDM_Item">
<Relationship parent="pos.CRDM_Header">
<RelatedField from="TransactionID" to="TransactionID" common-to-field="true" />
<RelatedField from="TradingDay" to="TradingDay" common-to-field="true" />
</Relationship>
</CollectionDescription>
<Description>TransactionID</Description>
</Field>
</LeftExpression>
</Field>
</Fields>
</Searchable>
Ниже приведен код PowerShell, который я пробовал:
$xmlFile = "C:\Users\rparpani\Desktop\test2.xml"
[xml]$xml = Get-Content $xmlFile -Raw
$nodes = $xml.SelectNodes("//Field[@id = 'item_transactionid']")
foreach ($node in $nodes)
{
$node.is-hidden-display-field = 'True'
}
xml.Save('C:\Users\rparpani\Desktop\test2.xml')
Похоже, существует другой способ обновления логический атрибут. Я пытаюсь изменить поле is-hidden-display-field с false на true. Может кто-нибудь подсказать, пожалуйста, что не так с моим кодом