Link to home
Start Free TrialLog in
Avatar of Stuart Dryden
Stuart DrydenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell import xml to array (non-cli xml)

Hi, after researching, reading source on github for any modules that bring in xml, checking out the contents of an export-clixml file it seems such a simple request yet such a complicated solution to want to read an XML file and put the contents in an array.  I can do it manually by using an online XML to  JSON convertor and then using ConvertFrom-Json but i need to automate this as part of my powershell script.

Is anyone aware of a command / function or powershell module that can read a valid XML file of any schema, construct the correct PSObject noteproperty members and populate it with the intended data from that XML file?

Kindest regards !!
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stuart Dryden

ASKER

Spot on, thanks very much.  you are correct my terminology was out - i should have said object (i think)

Its amazing that the result is so simple and i did get close - actually i succeeded in one of my many attempts but did not test it correctly drilling down through the elements and nodes as in your example .

Thanks for your help :)
Sometimes I find it difficult to visualize the XML if it didn't come from a file I can look at.  In those cases this may help.
$data | format-custom

Open in new window


Glad to help.
VERY cool !!

     :)