|
|
|
Helpful hint: When confronted with a wodge of hard to understand XML my favourite tool is XML Notepad 2007 available as a free download from Microsoft. I find the tree view in the editor is helpful understanding the XML structure.

The original poster in this thread was trying to extract information that matched certain criteria from an XML file and transfer it to a CSV file.
Windows PowerShell can do this stuff without even breaking a sweat. Here is an example. I downloaded an example XML file from Microsoft's MSDN site. It contains a catalogue of books with certain attributes. Here is the link to the file;
https://msdn.microsoft.com/en-us/library/ms762271(v=vs.85).aspx
To start I load the file contents into a PowerShell XML variable;
[xml]$library = Get-Content .\books.xml
My method is to traverse the XML down to the books node, pipe the output to a SELECT command to extract the required attributes for each book, pipe to a WHERE command to filter only the records we want, and then pipe the result to the Export-CSV commandlet to create a properly formatted CSV file with the information we want extracted. Here is the command;
$library.catalog.book | select title, author, genre |where {$_.genre -eq "Romance"} |Export-Csv romance.csv
All hail PowerShell!
Software Engineer
(the practice of real science, engineering and management)
A.I. (Automation rebranded)
Gender Neutral
(a person who believes in equality and who does not believe in/use stereotypes. Examples such as gender, binary, nonbinary, male/female etc.)
...they/their/them...
Thanks for all the replies.
We attended the DT meeting with the 15 pages of plain text text messages but they didn't even want to see it. They were aware of this dimwit and his antics and since he didn't bother to attend to defend himself, they pretty quickly found in our favour.
I still don't understand how I can get conditional formatting to colour the entire row, that is still something I'd be interested to know.
|
|
|