Jump to content
LaunchBox Community Forums

Using Powershell XML Parsing to get Favorites (and other) data


richardoswald

Recommended Posts

Hello fellow Launchboxers!

I ran into an issue where I restored Launchbox and I thought I lost all of my previous "Favorites". Luckily I backed up my old Launchbox to another folder and was able to find the XMLs that contained my favorites data! I was experimenting with parsing these files with Windows Powershell and since I found the syntax I figured I'd share it here in case anyone runs into a similar issue.

# For my example I wanted to get a list of of games I selected as my "Favorites" The Favorites are stored in the Platform XML files under your "Launchbox_Directory\Data\Platforms" folder

# Here you are adding the xml file you want to parse and store it into memory
PS F:\Programs\LaunchBox_old\Data\Platforms> [xml]$xmlDocument = Get-Content .\Arcade.xml

# This next command will look for all the games where Favorite is "true" and it will only print out the titles (instead of all the xml data)
PS F:\Programs\LaunchBox_old\Data\Platforms> $xmlDocument.LaunchBox.Game | where-object {$_.Favorite -eq "true"} | Select-Object Title

Title
-----
Caveman Ninja
Arkanoid
Alien vs. Predator
Teenage Mutant Ninja Turtles: Turtles in Time
Tron
Gun Force II
Tempest
Gun.Smoke
Pole Position
Centipede

 

Hopefully this will help some people out there and you can get creative with other parsing as well using the various fields in the xml. Another example could be:

$xmlDocument.LaunchBox.Game | where-object {$_.PlayMode -eq "2-Player Simultaneous"} | Select-Object Title

To get a list of all 2-player simultaneous games for that platform.

 

Just something small I figured out to hopefully add to the wealth of knowledge on here.

Edited by richardoswald
  • Like 2
Link to comment
Share on other sites

  • richardoswald changed the title to Using Powershell XML Parsing to get Favorites (and other) data

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...