I need to convert the below XML to CSV
<App>
<SecurityGroup name="Admin">
<Member username="John1" displayName="JohnDoe"/>
<Member username="Jane1" displayName="JoeDoe"/>
</SecurityGroup>
</App>
I tried the below one as well
$xml.app.childnodes | Select-Object @(
@{l="name";e={ $_.member.username}},
@{l="display";e={ $_.member.displayname }},
@{l="group";e={ $_.name }}
) | Export-CSV "c:/test.csv"
The format looks good but the username field and display name are all coming in the same field instead of individual rows
Security Group Username Displayname
Admin John1 Jane1 JohnDoe JaneDoe
I need the below format
SecurityGroup | Username | Displayname |
---|---|---|
Admin | John1 | JohnDoe |
Admin | Jane1 | JoeDoe |