Reputation: 97
I'm making an API call that returns the value in System.Xml.XmlElement
,
but it looks like this:
id : 5847538497
ipAddress : 192.168.110.1
status : RUNNING
upgradeStatus : UPGRADED
upgradeAvailable : false
Saving this in a local variable myData
. How can I print all the attributes of this returned XML?
It works if I type:
> Write-Host myData.id
> Write-Host myData.status
but I don't know all the attributes as api call is dynamic and returns different attributes.
Upvotes: 2
Views: 3738
Reputation: 174690
Take a look at the Attributes
property on the XmlElement
object in question:
$myData.Attributes |ForEach-Object {
'Name: {0}; Value: {1}' -f $_.LocalName,$_.Value
}
Upvotes: 3
Reputation: 58981
Take a look at the Format-List
and the Get-Member
cmdlet:
myData | Format-List * -force
myData | Get-Member
Upvotes: 2