powershell - How to find and replace by reading xml node value? -
following xml value.
<components> <component> <fullname>coreenvironment</fullname> <shortname>coreenv</shortname> </component> <component> <fullname>excel addin 2007</fullname> <shortname>excel_07</shortname> </component> </components> if user pass full name of component corresponding short name should displayed. able read particular node in xml using powershell. in case if 1 fullname node found corresponding shortname node should displayed. unable figure out logic this.
[xml]$xml="<components> <component> <fullname>coreenvironment</fullname> <shortname>coreenv</shortname> </component> <component> <fullname>excel addin 2007</fullname> <shortname>excel_07</shortname> </component> </components>" $test="excel addin 2007" $xml.components.component |% { if( $_.fullname -match $test) { write-host $_.shortname}}
Comments
Post a Comment