pepco
pepco

Reputation: 67

powershell xml variable encoding

I'm invoking web services to retrieve XML data. I save response to xml variable:

$Response = Invoke-WebRequest $newURL -Method Post -Headers @{SOAPAction=$newURL} -ContentType "text/xml" -Body $queryBody

Result of the web service is xml with UTF-8 encoding in the header section.

However when I access some elements i.e. like this:

$response.Envelope.Body.describeSObjectResponse.result.fields[4].picklistValues

I can see that some values are converted to ascii because some national characters are replaced with character "?".

Could you please advise how can I read these elements in UTF-8 encoding?

EDIT 1.3.2014:
Seems like the problem is with the Invoke-WebRequest. If I redirect output with -outfile switch to file, the encoding in the file is correct. If I then load content of the xml file into xml variable encoding is still correct.

Any ideas, how I can achieve the same but without redirecting the output to the file; i.e. working directly inside powershell logic?

Upvotes: 2

Views: 789

Answers (1)

Keith Hill
Keith Hill

Reputation: 201602

It looks like you may be running into a bug with this command. If this Connect issue looks what you're seeing, be sure to vote on it.

Upvotes: 1

Related Questions