Mastering PowerShell Scripting - Fourth Edition by Chris Dent

Mastering PowerShell Scripting - Fourth Edition by Chris Dent

Author:Chris Dent [Chris Dent]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2021-06-28T16:00:00+00:00


Modifying the value of an attribute uses the same syntax:

[XDocument]$xDocument = @" <?xml version="1.0"?> <list name='letters'> <name>1</name> </list> "@ $xDocument.Element('list').Attribute('name').Value = 'numbers'

If the attribute does not exist, an error will be thrown:

PS> $xDocument.Element('list').Attribute('other').Value = 'numbers' InvalidOperation: The property 'Value' cannot be found on this object. Verify that the property exists and can be set.

The changes made by the preceding assignments may be viewed in the xDocument variable:

PS> $xDocument.ToString() <list name="numbers"> <name>1</name> </list>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.