extracting post details from wordpress xml dump with powershell

Get the xml into a variable

[xml]$xmla = get-content D:\repair_websites\salisburywiltshireandstonehenge.wordpress.2015-10-03.xml                       

Extract the details

select-xml -xml $xmla -xpath "//channel/item" | select -expandproperty node | ? post_type -ne "attachment" | select title  

gives the following:

title                        
-----                        
Road names beginning with 'N'
Road names beginning with 'O'
Road names beginning with 'P'
Road names beginning with 'Q'
Road names beginning with 'R'
Road names beginning with 'S'
Road names beginning with 'T'
Road names beginning with 'U'
Road names beginning with 'V'
Road names beginning with 'W'

The properties of the expanded node are:
wordpress-xml-powershell-properties

For example:

select-xml -xml $xmla -xpath "//channel/item" | select -expandproperty node | ? post_type -ne "attachment" | ? title -like "*Ramone*"

outputs:

title          : 3rd June 1977 - the Ramones visit Stonehenge. Johnny stays on the bus
link           : http://salisburyandstonehenge.net/on-this-day/june/3rd-june-1977-the-ramones-visit-stonehenge-johnny-stays-on-the-bus
pubDate        : Tue, 04 Nov 2014 12:33:09 +0000
creator        : creator
guid           : guid
description    : 
encoded        : {content:encoded, excerpt:encoded}
post_id        : 9267
post_date      : 2014-11-04 12:33:09
post_date_gmt  : 2014-11-04 12:33:09
comment_status : open
ping_status    : closed
post_name      : 3rd-june-1977-the-ramones-visit-stonehenge-johnny-stays-on-the-bus
status         : publish
post_parent    : 6624
menu_order     : 3
post_type      : page
post_password  : 
is_sticky      : 0
postmeta       : {wp:postmeta, wp:postmeta, wp:postmeta, wp:postmeta}

To get the actual content of the post:

select-xml -xml $xmla -xpath "//channel/item" | select -expandproperty node | ? post_type -ne "attachment" | ? title -like "*Ramone*" | select -ExpandProperty encoded | fl

…gives:

#cdata-section : <a href="http://salisburyandstonehenge.net/images/Joey-Ramone-visited-Stonehenge.jpg"><img src="http://salisburyandstonehenge.net/images/Joey-Ramone-visited-Stonehenge.jpg" alt="Joey Ramone - 'visited' 
                 Stonehenge" width="320" height="455" class="alignright size-full wp-image-9702" /></a>On either the 3rdIn 'On the Road with 
                 the Ramones', Monte A. Melnick says that the visit occurred 

                 <blockquote>'On the '77 tour we had a day off and noticed Stonehenge was on the way'[URL <a href="http://books.google.co.uk/books?
                 id=N7m8AwAAQBAJ&lpg=RA1-PR24&dq=ramones%20stonehenge&pg=RA1-PR25#v=onepage&q=ramones%20stonehenge&f=false">'On the Road with the 
                 Ramones', by By Monte A. Melnick, Frank Meyer</a>].</blockquote>

                 This would have been when the Ramones were travelling back from Penzance to Canterbury - the free day being June 3rd [<a href="http://en.wikipedia.org/wiki/List_of_Ramones_concerts#1977">Wikipedia List Of Ramones Concerts</a>] or possibly the 
                 4th June 1977, the Ramones visited Stonehenge.

                 Pic: By en:User:Dawkeye [<a href="http://www.gnu.org/copyleft/fdl.html">GFDL</a>, <a href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA-3.0</a> or <a href="http://creativecommons.org/licenses/by-sa/2.5">CC-BY-SA-2.5</a>], <a href="http://commons.wikimedia.org/wiki/File%3AJoeyramone.jpg">via Wikimedia Commons</a>

                 More:

                 <a href="http://books.google.co.uk/books?id=c7lgKVmD0yMC&lpg=PA170&dq=ramones%20stonehenge&pg=PA171#v=onepage&q=ramones%20stonehen
                 ge&f=false" title="http://books.google.co.uk/books?id=c7lgKVmD0yMC&lpg=PA170&dq=ramones%20stonehenge&pg=PA171#v=onepage&q=ramones%
                 20stonehenge&f=false">I Slept with Joey Ramone: A Family Memoir By Mickey Leigh</a>

                 <a href="http://books.google.co.uk/books?id=N7m8AwAAQBAJ&lpg=RA1-PR24&dq=ramones%20stonehenge&pg=RA1-PR25#v=onepage&q=ramones%20st
                 onehenge&f=false" title="http://books.google.co.uk/books?id=N7m8AwAAQBAJ&lpg=RA1-PR24&dq=ramones%20stonehenge&pg=RA1-PR25#v=onepag
                 e&q=ramones%20stonehenge&f=false">On the Road with the Ramones By Monte A. Melnick, Frank Meyer</a>

                 <a href="http://books.google.co.uk/books?ei=AxPJU5u3Jae60QXB1ICQBQ&id=QTjaAAAAMAAJ&dq=ramones+stonehenge&focus=searchwithinvolume&
                 q=+stonehenge" title="http://books.google.co.uk/books?ei=AxPJU5u3Jae60QXB1ICQBQ&id=QTjaAAAAMAAJ&dq=ramones+stonehenge&focus=search
                 withinvolume&q=+stonehenge">A Time to Rock: A Social History of Rock and Roll by David P. Szatmary</a>


#cdata-section : 
Advertisements