I have a gpx file, which is just xml, and want to run a powershell script to delete the < time > node.
<trkpt lat="-33.483478" lon="150.159805">
<name> p2 </name>
<time>2021-02-23T00:00:12Z</time>
</trkpt>
<trkpt lat="-33.483852" lon="150.158309">
<name> p3 </name>
<time>2021-02-23T00:00:56Z</time>
</trkpt>
<trkpt lat="-33.483943" lon="150.157897">
<name> p4 </name>
<time>2021-02-23T00:01:07Z</time>
</trkpt>
<trkpt lat="-33.484066" lon="150.157592">
<name> p5 </name>
<time>2021-02-23T00:01:17Z</time>
</trkpt>
each line ends in just LF or \n. I want to delete the < time > node including the newline.
I know I have the correct newline, or EOL, because I can see this clearly in Notepad++ and the regex in this works perfectly <time>(.*?)</time>\n
.
so I use powershell with this code:
(gc test.gpx) -replace '<time>(.*?)</time>`n', '' | Out-File -encoding ASCII processed1.gpx
all my research shows newline for powershell is `n
(not \n
). I have also tried `r`n
and double quotes "`n"
or "`r`n"
just in case, and its just not working. I have searched similar questions and their answers dont seem to work for me.
Help appreciated!!
Ben