access #text property of XMLAttribute in powershell

Besides #text, you can also access XmlAttribute's value via Value property :

$attr = $xml.SelectSingleNode("//obj/indexlist/index[@name='DATE']/@value")

#print old value
$attr.Value

#update attribute value 
$attr.Value = "new value"

#print new value
$attr.Value

Note that Value in $attr.Value is property name of XmlAttribute. It doesn't affected by the fact that the attribute in your XML named value.


Don't select the attribute, select the node. The attributes of the node will be represented as properties and can be modified as such:

$node = $xml.SelectSingleNode("//obj/indexlist/index[@name='DATE']")
$node.value = 'foo'

Use a loop if you need to modify several nodes:

$nodes = $xml.SelectNodes("//obj/indexlist/index[@name='DATE']")
foreach ($node in $nodes) {
  $node.value = 'foo'
}