Piping CURL output to XML - unreadable?

Code does as follows.

./curl.exe --insecure --http1.1 --tlsv1.2 --url "https://$IP/cgi-bin/NAXML?cmd=vposjournal&period=2&filename=$URL&cookie=$cookie2" | out-file "C:\sdirectory\SAVEDFILE.xml"


However, this XML file (A valid XML) is not readable in browsers.

Is out-file the best way to export this to disk? Is there a more viable alternative?

Can you share the $ip? You can try set-content instead of out-file, since out-file encodes in unicode. Instead of curl you can try invoke-webrequest or invoke-restmethod. I don’t see how xml can be valid but not readable by a browser.

You could use the native curl option –output to write the output to a file instead of the standard out (console). To learn more about the available options for curl you should run

curl.exe --help