Link to home
Start Free TrialLog in
Avatar of mikeydk
mikeydkFlag for Denmark

asked on

Add to XML (Powershell)

Hey

XML-file:
<Corp>
      <employee id="123">
             <name>John</name>
             <status>1</status>
       </employee> 
</Corp>		

Open in new window


Powershell:
$myfile = [xml] (Get-Content ("C:\Users\mic\Desktop\doc.xml") -Encoding UTF8)
$employees = $myfile.SelectNodes("//employee")

foreach($employee in $employees)
{
    $employee.id
    $employee.name
}

Open in new window

     
How do I add:  (in the powershell part)

      <employee id="123">
            <name>John</name>
            <status>1</status>
               <salary>10000</salary> ?
      </employee>
ASKER CERTIFIED SOLUTION
Avatar of Swapnil
Swapnil
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial