How to fetch an attribute value from xml using powershell?
Assuming your XML structure is something similar to:
$xml = [xml]'
<Events>
<Event Definition="Validate" DLLPath="" DLLName="Helper.dll" DLLClass="HelpMain" DLLRoutine="pgFeatureInfoOnValidate_WriteToRegSelectedFeatures" InputParameters="pTreeViewFeatureTreeServerOS" RunOnce="no"/>
<Event Definition="Validate1" DLLPath="" DLLName="Helper.dll1" DLLClass="HelpMain1" DLLRoutine="pgFeatureInfoOnValidate_WriteToRegSelectedFeatures" InputParameters="pTreeViewFeatureTreeServerOS" RunOnce="no"/>
</Events>
'
#Or get it from a XML file
$xml = [xml](Get-Content $XMLPath)
$xml.Events.Event | Select DLLName
you can use also xpath instead of dot notation:
$xml.SelectNodes('//Events/Event') | select DLLName
Assuming your Event
element has an Events
element root:
$xml.Events.Event.DLLName
I've only tested this in Powershell 3