
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Update Specific Node of XML File Using PowerShell
To update the specific XML node using PowerShell, we first need to select that node with the attribute with SelectSingleNode() method.
We have below the XML file from the link stored in SampleXml.XML on C:\Temp location.
In this example, we are going to update Autor and Genre properties of the Book having attribute Id = ‘bk102’
$xml=[xml](Get-Content C:\Temp\SampleXML.xml)
$node=$xml.SelectSingleNode("//book[@id='bk102']")
The above commands will load the XML file and select node with attribute value ‘bk102’.
$node.genre='Non-Fiction' $node.author='Dell James' $xml.Save("C:\Temp\SampleXML.xml")
The above commands will update the genre and author property.
Advertisements