How to replace angle brackets?

Hi all,

I have some data like this in a XML file:

<?xml version="1.0" standalone="yes"?>

I am trying to remove this completely and save the xml file but its not removing the angle brackets.

My expression is like this:
(Get-Content test.xml) -replace ‘<?xml version=?"1.0"? standalone=?"yes"?>’, ‘’ | Set-Content -encoding UTF8 test.xml

Can anyone guide me how to remove “< >” brackets?

Hi, welcome back :wave:

Firstly, when posting code in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working).

How to format code on

The code in your post doesn’t remove anything for me. Try escaping the ?

(Get-Content test.xml) -replace '<\?xml version=\?"1.0"\? standalone=\?"yes"\?>', '' | 
    Set-Content -encoding UTF8 test.xml
1 Like