Set-OpenXmlString

Following is a screen-cast that shows how to use Set-OpenXmlString.

One of the problems of search-and-replace is that the string that matches the search string could be broken up into multiple runs.  If you are interested in the algorithm that Set-OpenXmlString uses for searching and replacing, see Introducing TextReplacer: A New Class for PowerTools for Open XML.  While the screen-cast shows only the algorithm for WordprocessingML, the algorithm for PresentationML is nearly identical.  For a slightly different take on search-and-replace, see Search and Replace Text in an Open XML WordprocessingML Document, which shows the algorithm using XmlDocument instead of LINQ to XML and a functional programming approach.

This code uses an approach similar to that of Merge-OpenXmlDocumentComment.