Execute Intelij IDEA code format when committing - github

I would like to apply a code format action before I'm commiting.
Currently I have xml eclipse file that would define the format I would apply.
Since I have gradle and spotless I declared an action such as:
spotless {
enforceCheck false
java {
licenseHeaderFile "${rootDir}/LICENSE"
// licenseHeaderFile "${rootDir}/LICENSE"
eclipse().configFile("eclipse/formater.xml")
}
}
That is triggered by a shell script that is a git hook:
#!/bin/bash
set -e
toFormat="$(git --no-pager diff --name-status --cached | awk '$1 != "D" && $2 ~ /\.kts|\.java|\.kt/ { print $NF}')"
echo "Will format the files:"
echo $toFormat | tr " " "\n"
for fileToFormatPath in $eligibleToFormat
do
./gradlew spotlessApply -PspotlessIdeHook="$(pwd)/$fileToFormatPath"
git add $fileToFormatPath
done;
And so far it is working.
Now I would like to do it but directly using the declared IDEA xml formater such as:
<code_scheme name="formater" version="173">
<JavaCodeStyleSettings>
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="120" />
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="2" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="2" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="2" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="5=4" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="5" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
I don't find much idea on the internet, any suggestion ?

Related

MongoDB Persistency when deploying to Kubernetes via VSCode Cloud Studio

I am trying to use VSCode Cloud Studio plugin to deploy and debug a project in Kubernetes. When I use intellij and Cloud Studio plugin there, everything works perfect. My MongoDB is persistent with each deployment. When I use VSCode and Cloud Studio there, MongoDB is not persistent anymore. I would appreciate any tips to make it work in VSCode too.
When I deploy via intellij it uses the same persistent volume claim. When I deploy via VSCode it creates a new persistent volume claim everytime.
Here is the launch.json for VSCode:
{
"configurations": [
{
"name": "Kubernetes: Run/Debug",
"type": "cloudcode.kubernetes",
"request": "launch",
"skaffoldConfig": "${workspaceFolder}\\skaffold.yaml",
"watch": false,
"cleanUp": false,
"portForward": true,
"imageRegistry": "XYZ",
"debug": [
{
"image": "XYZ",
"containerName": "XYZ",
"sourceFileMap": {
"${workspaceFolder}": "/root/"
}
}
]
}
]
}
Here is the workspace.xml from intellij:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b5a077d4-323a-4042-8c4a-3bdd2d997e47" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2KV2OUqPUEf43q5Aj0UCGkKKm10" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="com.google.cloudcode.ide_session_index" value="20230118_0001" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="ts.external.directory.path" value="C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\JavaScriptLanguage\jsLanguageServicesImpl\external" />
</component>
<component name="RunDashboard">
<option name="excludedTypes">
<set>
<option value="gcp-app-engine-local-run" />
</set>
</option>
</component>
<component name="RunManager">
<configuration name="Develop on Kubernetes" type="google-container-tools-skaffold-run-config" factoryName="google-container-tools-skaffold-run-config-dev" show_console_on_std_err="false" show_console_on_std_out="false">
<option name="allowRunningInParallel" value="false" />
<option name="buildEnvironment" value="Local" />
<option name="cleanupDeployments" value="false" />
<option name="deployToCurrentContext" value="true" />
<option name="deployToMinikube" value="false" />
<option name="envVariables" />
<option name="imageRepositoryOverride" />
<option name="kubernetesContext" />
<option name="mappings">
<list />
</option>
<option name="moduleDeploymentType" value="DEPLOY_MODULE_SUBSET" />
<option name="projectPathOnTarget" />
<option name="resourceDeletionTimeoutMins" value="2" />
<option name="selectedOptions">
<list />
</option>
<option name="skaffoldConfigurationFilePath" value="$PROJECT_DIR$/skaffold.yaml" />
<option name="skaffoldModules">
<list>
<option value="XYZ" />
</list>
</option>
<option name="skaffoldNamespace" />
<option name="skaffoldProfile" />
<option name="skaffoldWatchMode" value="ON_DEMAND" />
<option name="statusCheck" value="true" />
<option name="verbosity" value="WARN" />
<method v="2" />
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="b5a077d4-323a-4042-8c4a-3bdd2d997e47" name="Changes" comment="" />
<created>1674045398429</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1674045398429</updated>
<workItem from="1674045401219" duration="2543000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>
All other files are the same for the project of course.
It looks like the Cloud Code for IntelliJ configuration is restricting the deployment to the XYZ module, but not in the Cloud Code for VS Code configuration.

how to add dynamic class name in thymeleaf in select option?

i submit with model to template
in template
i used th:each and in th:each i used select option
i want to dynamically add select's class name
"${cos_seq}" is int so i add 'abc'
<th:each="row:${Basket}">
<select class="'abc'+'${row.cos_seq}'"
th:value="${row.cos_seq}" style="float:left;margin-
right:5px ;width:45px;height:42px;" >
<option
class="qty-option" value="1" text="1"
style="width:20px">1</option>
<option
class="qty-option" value="2" text="2"
style="width:20px">2</option>
<option
class="qty-option" value="3" text="3"
style="width:20px">3</option>
<option
class="qty-option" value="4" text="4"
style="width:20px">4</option>
<option
class="qty-option" value="5" text="5"
style="width:20px">5</option>
<option
class="qty-option" value="6" text="6"
style="width:20px">6</option>
<option
class="qty-option" value="7" text="7"
style="width:20px">7</option>
<option
class="qty-option" value="8" text="8"
style="width:20px">8</option>
<option
class="qty-option" value="9" text="9"
style="width:20px">9</option>
<option
class="qty-option" value="10+" text="10+"
style="width:20px">10+</option>
</select>

How to move the “Recently Viewed Products” widget in magento2?

I have added the 'Recently viewed products' widget on the product view page(2 columns left). Currently, it's showing below the product info details section. But I want it full width. So I want to move this widget into the main content area or above the footer.
so how to move this section? If anyone knows please let me know.
Thanks.
In vendor/magento/module-catalog/etc/widget.xml you see the containers section. This means the recently viewed products can only be placed in the sidebar main, content and sidebar additional containers.
<widget id="catalog_recently_viewed" class="Magento\Catalog\Block\Widget\RecentlyViewed"
placeholder_image="Magento_Catalog::images/product_widget_viewed.png">
<label translate="true">Recently Viewed Products</label>
<description translate="true">List of Products Recently Viewed by Visitor</description>
<parameters>
<parameter name="uiComponent" xsi:type="text" required="false" visible="false">
<label translate="true">UI Component</label>
<value>widget_recently_viewed</value>
</parameter>
<parameter name="page_size" xsi:type="text" required="true" visible="true">
<label translate="true">Number of Products to display</label>
<value>5</value>
</parameter>
<parameter name="show_attributes" xsi:type="multiselect" required="true" visible="true">
<label translate="true">Product attributes to show</label>
<options>
<option name="name" value="name">
<label translate="true">Name</label>
</option>
<option name="image" value="image">
<label translate="true">Image</label>
</option>
<option name="price" value="price">
<label translate="true">Price</label>
</option>
<option name="learn_more" value="learn_more">
<label translate="true">Learn More Link</label>
</option>
</options>
</parameter>
<parameter name="show_buttons" xsi:type="multiselect" required="true" visible="true">
<label translate="true">Buttons to show</label>
<options>
<option name="add_to_cart" value="add_to_cart">
<label translate="true">Add to Cart</label>
</option>
<option name="add_to_compare" value="add_to_compare">
<label translate="true">Add to Compare</label>
</option>
<option name="add_to_wishlist" value="add_to_wishlist">
<label translate="true">Add to Wishlist</label>
</option>
</options>
</parameter>
<parameter name="template" xsi:type="select" required="true" visible="true">
<label>Template</label>
<options>
<option name="grid" value="product/widget/viewed/grid.phtml" selected="true">
<label translate="true">Viewed Products Grid Template</label>
</option>
<option name="list" value="product/widget/viewed/list.phtml">
<label translate="true">Viewed Products List Template</label>
</option>
<option name="sidebar" value="product/widget/viewed/sidebar.phtml">
<label translate="true">Viewed Products Sidebar Template</label>
</option>
</options>
</parameter>
</parameters>
<containers>
<container name="sidebar.main">
<template name="default" value="sidebar" />
</container>
<container name="content">
<template name="grid" value="grid" />
<template name="list" value="list" />
</container>
<container name="sidebar.additional">
<template name="default" value="sidebar" />
</container>
</containers>
</widget>
You can try adding an etc/widget.xml in a custom module and add containers for the recently viewed widget in the container node. For example in page.top (After Page Header).
<container name="page.top">
<template name="grid" value="grid" />
<template name="list" value="list" />
</container>
In Extending a Magento widget layout within a theme is explained how to extend a widget in the widget xml.

How to Modify XML File using Powershell

Hi Friends i want to modify some Text value in <Option Name="Activate">1</Option> to <Option Name="Activate">0</Option>. I am unable to locate node value <Option Name="Activate">1</Option> using powershell. below is the full code section in which i want to modify the Text. Please help.
<User Name="Richard">
<Option Name="Pass">b56e0b4ea4962283bee762525c2d490f</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback"></Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
Download XML File Here
So far i have tried Below Code but unable to complete. :(
$xml = New-Object XML
$XML.Load("D:\PSScript\BookStore.xml")
$xml.bookstore.Users.user |
Where-Object { ($_.Name -eq 'Richard')} |
Select-Object -Property Option
**Note : I want to use a condition here for example i want to change 1 Tag text value only for specific user, In short i want to modify text based on user id, Like where name = Richard change its <Option Name="Activate">1</Option> to <Option Name="Activate">0</Option> **
<BookStore>
<Settings>
<Item name="Admin port" type="numeric">88881</Item>
</Settings>
<Container>
<Containers Name="MasterVal">
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\reports">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\NT">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\WIN">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\Winsxs">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\SXS">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">1</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">1</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="1" DlLimit="10" ServerDlLimitBypass="0" UlType="1" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</Containers>
<Containers Name="DMPL(9990)-D">
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder\MST">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST\NT\Report_9990">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="1" DlLimit="10" ServerDlLimitBypass="0" UlType="1" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</Containers>
</Container>
<Users>
<User Name="leonardo">
<Option Name="Pass">05538eb07b4dbf66b1da4ea9374ac8f5</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="repturet">
<Option Name="Pass">e076fc6c4c8a245beec106646719f738</Option>
<Option Name="Containers">
</Option>
<Option Name="Max Limit Allowed">0</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">0</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations>
<Authorization path="E:\BookMaster\RootFolder\MST\NT">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">1</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">0</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
<Authorization path="E:\BookMaster\RootFolder\MST">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">0</Option>
<Option Name="FileDelete">0</Option>
<Option Name="FileAppend">0</Option>
<Option Name="pathCreate">0</Option>
<Option Name="pathDelete">0</Option>
<Option Name="pathList">1</Option>
<Option Name="pathSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Authorization>
</Authorizations>
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="Anuj">
<Option Name="Pass">270a8eaf5877a08bc69bdde947f8e8b6</Option>
<Option Name="Containers">DMPL(9990)-D</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="pallavi">
<Option Name="Pass">8d644bb6af9f1822de1d668d0ea6c36a</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="piyush">
<Option Name="Pass">db699a999e4a6c8bd867720850d3007c</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
<User Name="Richard">
<Option Name="Pass">b56e0b4ea4962283bee762525c2d490f</Option>
<Option Name="Containers">MasterVal</Option>
<Option Name="Max Limit Allowed">2</Option>
<Option Name="Limit Allowed">0</Option>
<Option Name="User Limit">0</Option>
<Option Name="Activate">1</Option>
<Option Name="Feedback">
</Option>
<Option Name="ForceSsl">2</Option>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
</Users>
</BookStore>
Your main problem is you need to treat option elements as arrays. I copied your xml snippet to a file called test.xml and this code works (I'll explain how I parsed through your xml file at each step to show where Option is displaying as an array):
[xml] $info = Get-Content test.xml #Shorthand for New-Object..Load
#This command isn't necessary but is helpful when looking for an attribute
$info | Format-List *
#From above command saw that $info.User is the base document element
$info.User
#showed Attribute in Option
$info.User.Option
#displayed an array element with Attribute as the 5 (6th cause you start at 0) index
$info.User.Option[5]
#displayed Name and #text attributes with #text = 1
$info.User.Option[5].'#text' = "0"
#updated #text attribute to 0
From this you should be able to modify your script to work with the full xml file.
As your still having problems, a better solution would be to adjust your xml so you can access each user as a full object rather then parsing through attributes:
<User>
<name>Richard</name>
<pass>b56e0b4ea4962283bee762525c2d490f</pass>
<containers>MasterVal</containers>
<maxLimit>2</maxLimit>
<minLimit>0</minLimit>
<userLimit>0</userLimit>
<activate>1</activate>
<feedback></feedback>
<forceSsl>2</forceSsl>
<FileAllowed>
<Disallowed />
<Allowed />
</FileAllowed>
<Authorizations />
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0"
UlLimit="10" ServerUlLimitBypass="2">
<Download />
<Upload />
</SpeedLimits>
</User>
Then you can access each user as $info.User.Richard and change each activate tags using $info.User.Richard.activate = 0. If you cannot do this you'll need to use foreach:
[xml] $info = Get-Content test.xml
foreach ($i in $info.BookStore.Users.User) {
if ($i.Name -eq "Richard") {
foreach ($e in $i.Option) {
if ($e.Name -eq "Activate") {
$e.'#text' = "0"
}
}
}
}
Then just write the xml back to the file. Note: Look at the use of select and select-xml if you want to simplify this later
Updated: with full answer given xml file

Forms - Select list not working, but check boxes do

What is the error that is not allowing the below select list to work?
Creating an email sign up form (Constant Contact). Using the Constant Contact form generator, I attempted to change the "mailing lists options" from check boxes to a drop down menu—but doing so caused the contact info to be added to all the mailing lists, and not the single list that was selected.
Select list code: (not working)
<select>
<option name="Customer Type" ID="">Please select...</option>
<option value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />Architect/Designer</option>
<option value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />AV/Media/Broadcast</option>
<option value="Command/Control" name="Lists[]" id="list_Command/Control" />Command/Control</option>
</select>
Check box code: (working)
<input type="checkbox" checked="checked" value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />
<label for="list_Architect/Designer">Architect/Designer</label><br />
<input type="checkbox" value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />
<label for="list_AV/Media/Broadcast">AV/Media/Broadcast</label><br />
<input type="checkbox" value="Command/Control" name="Lists[]" id="list_Command/Control" />
<label for="list_Command/Control">Command/Control</label><br />
you need select to be multiple
<select multiple='multiple'>
<option name="Customer Type" ID="">Please select...</option>
<option value="Architect/Designer" name="Lists[]" id="list_Architect/Designer" />Architect/Designer</option>
<option value="AV/Media/Broadcast" name="Lists[]" id="list_AV/Media/Broadcast" />AV/Media/Broadcast</option>
<option value="Command/Control" name="Lists[]" id="list_Command/Control" />Command/Control</option>
</select>