Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Unable to read XML file in Powershell

$
0
0

Hi Experts,

My xml file format as below.

<DocumentRoot>

-<AQT_Output>

<Surname>LOVE</Surname>

<Given_Names>Richard James</Given_Names>

<Email_Address>Richard.Love@XYZ.com.au</Email_Address>

<Employee_ID>1348</Employee_ID>

<Employee_Number>030-41633</Employee_Number>

<User_Name>RJLOVE</User_Name>

<Position_Title>Customer Service Officer</Position_Title>

<Area_ID>AAB01</Area_ID>

<Area_Description> House 1st Floor</Area_Description>

<Department_ID>810</Department_ID>

<Department> Retail.Customer Services.Billing</Department>

<Supervisor_Emp_No>9331</Supervisor_Emp_No>

<Supervisor_ID>7692</Supervisor_ID>

<Supervisor_User_ID>kbritton</Supervisor_User_ID>

<ESS_Authority_Level>1</ESS_Authority_Level>

</AQT_Output>

-<AQT_Output>

<Surname>OCHMANSKI</Surname>

<Given_Names>Danuta</Given_Names>

<Email_Address>Danuta.Ochmanski@XYZ.com.au</Email_Address>

<Employee_ID>352</Employee_ID>

<Employee_Number>030-42097</Employee_Number>

<User_Name>D_OCHMANSKI</User_Name>

<Position_Title>Technical Officer</Position_Title>

<Area_ID>GRENWW</Area_ID>

<Area_Description>Greenway West</Area_Description>

<Department_ID>605</Department_ID>

<Department>Network Services.Customer Service.Design</Department>

<Supervisor_Emp_No>527-42110</Supervisor_Emp_No>

<Supervisor_ID>371</Supervisor_ID>

<Supervisor_User_ID>DKCHAN</Supervisor_User_ID>

<ESS_Authority_Level>1</ESS_Authority_Level>

</AQT_Output>

</DocumentRoot>

I am unable to read XML file users attributes. Using the below Powershell script

[Xml]$xmldata=Get-Content D:\BackUp\pmis.XML
$xmldata.DocumentRoot
$xmldata.DocumentRoot.AQT_OUTPUT
#$xmldata.content.text | select English | Export-CSV D:\Backup\test123.csv -notype

$objectNodes = $xmldata.SelectNodes('/DocumentRoot/AQT_OUTPUT')
foreach($objectNodes in $xmldata.DocumentRoot.AQT_Output)
{
    Write-Host $objectNodes.Surname
}

Above script is giving me below output but i need to read Users Output. For instance, Suraname, Email ID etc

AQT_Output                                                                                                                                                                                                            
----------                                                                                                                                                                                                            
{AQT_Output, AQT_Output, AQT_Output, AQT_Output...}     

Any suggestions how should i proceed further. Thanks.


Warm Regards Badal Ratra




Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>