Asked by:
Reading XML

General discussion
-
Hello,
I have an xml file with me and I have to read that file by the PowerShell. Is it possible to read the xml file output by the PowerShell?
Regards,
Shashank
shashank saxena
- Changed type Bill_Stewart Friday, July 27, 2018 6:07 PM
- Moved by Bill_Stewart Friday, July 27, 2018 6:07 PM This is not "fix/debug/rewrite this script I found on the Internet" forum
Friday, April 13, 2018 6:39 PM
All replies
-
What have you tried?
This is not the right place to ask other people to train you in PowerShell basics or write code for you.
-- Bill Stewart [Bill_Stewart]
Friday, April 13, 2018 6:53 PM -
Are you asking how to load an XML file? WHat d you mena by reading the "output"?
To load XML:
[xml]$xml = Get-Content yourfile.xml
\_(ツ)_/
- Edited by jrv Friday, April 13, 2018 6:56 PM
Friday, April 13, 2018 6:55 PM -
Hello,
I wrote this code:
$r = Import-Clixml <location with file name and
extension>$r | fl | more
$r.Report
$r.Report.Failures
|fl$r.Report.Failures
|Select
-Last 1$i=0;$r.report.Failures | foreach { $_ | Select-Object @{name="index";expression={$i}},timestamp,failurecode,failuretype,failureside;$i++} | ft
But it is giving an error.
Regards,
Shashank
shashank saxena
Monday, April 16, 2018 5:56 PM -
If you have a new question please start a new topic and provide an example of the data and the complete error message. This topic has been answered.
\_(ツ)_/
Monday, April 16, 2018 5:58 PM -
Hello,
Thanks for the reply. "Reading the Output" means, we have a xml file and that file is not a human friendly in the perspective of reading, so I want that command to read the xml file just like the output of a command when we run in PowerShell.
Regards,
Shashank
shashank saxena
Monday, April 16, 2018 6:01 PM -
Your question is very vague and ambiguous. XML file can be loaded as I showed you. CliXML files are very special files that can save PowerShell objects. The commands are not designed to load (read) general XML files.
Please do a little research on PowerShell and XML in order to understand why your question is ambiguous and impossible to answer as asked.
\_(ツ)_/
Monday, April 16, 2018 6:05 PM