I recently had a need to read data from an xml configuration file that was stored within a SharePoint library.  To make things easier I of course went to Google (or Bing) and checked to see if someone else had yet blogged this.  Couldn’t find anything, so in order to help out someone else that may need to do the same at some point, I wrote up a quick little blog.  Note: this will only work for on-premises versions of SharePoint.  I’ll update with a SharePoint Online version in the future.  I’ll also write up how to add and delete contents in a future post as well.

Read XML Data Files Stored in a SharePoint Library with PowerShell

Basically the steps are as follows:

  1. Get the SPWeb object of the site where the file is contained
  2. Get the file using the URL
  3. Open the file
  4. Apply ASCII Encoding to the open file
  5. Cast the file object as xml
  6. Profit…

Here’s the code to accomplish what you need:

Once you have completed the above you now have an xml object you can use for what ever you need.

 

Thanks for reading!!