Can someone please help me to do the following more efficiently? I am running this code 4 times for updating specific below protocols/file types. I would like to do it in a loop or other ways to make it much more efficient!
$XMLPATH = 'C:\DefaultAssociation.xml'
$xml = [xml](Get-Content $XMLPATH -raw)
#update .htm
$htm = ($xml.DefaultAssociations.Association | where-Object Identifier -eq '.htm')
$htm.SetAttribute('ProgId', "ChromeHTML")
$htm.SetAttribute('ApplicationName', "Google Chrome")
#update .html
$html = ($xml.DefaultAssociations.Association | where-Object Identifier -eq '.html')
$html.SetAttribute('ProgId', "ChromeHTML")
$html.SetAttribute('ApplicationName', "Google Chrome")
#update .https
$https = ($xml.DefaultAssociations.Association | Where-Object Identifier -eq 'https')
$https.SetAttribute('ProgId', "ChromeHTML")
$https.SetAttribute('ApplicationName', "Google Chrome")
#update http
$http = ($xml.DefaultAssociations.Association | Where-Object Identifier -eq 'http')
$http.SetAttribute('ProgId', "ChromeHTML")
$http.SetAttribute('ApplicationName', "Google Chrome")
$XML.SAVE($XMLPATH)
instead of running it multiple times, I need to make it an array or some sort of loop, so it doesn't read the XML file multiple times. How can this be done more efficiently?