• Not Answered

How to edit/remove some HTML tags or attributes using Sitecore Powershell?

I am already able to loop through all of the items with a particular tempalteID and show their name, path, and value of the content field.

Current Code:

$_BlogListingFolder = '/sitecore/content/path...'
$_BlogContentTemplateID = '{F542FC85-053E-...-B81A-F7C1FFB68DCC}'
$reportObjects = @()

$allBlogContent = Get-ChildItem -Path $_BlogListingFolder -Recurse | Where-Object{$_.TemplateID -eq 
$_BlogContentTemplateID };

foreach($v in $allBlogContent){
   $reportObjects += $v

$reportObjects | Show-ListView -Property @{Label="Redirect Name"; Expression={ $_.Name } } , @{Label="Path"; Expression={ $_.Paths.Path }}, @{Label="Content"; Expression={ $_.Fields["Content"] } }

The reason I'm doing this is to be able to remove anchor tags with particular hrefs (or parts of hrefs) but keep their text.

Example 1: Remove the anchor tag entirely

<a href="google.com">To Google!</a>

Would turn into:

To Google!

Example 2: Remove part of an HREF

<a href="google.com/someChild/someGrandChild">To Googles Grand Child!</a>

Would turn into:

<a href="google.com/someChild">To Googles Grand Child!</a>