July 14, 2021 at 7:30 am
Hello Everyone,
While parsing XML files in SSIS i am getting an error “Invalid character in given encoding”.
I can overcome this issue by manually replacing first line of code
<?xml version="1.0"?>
With below line of code
<?xml version="1.0" encoding="ISO-8859-1" ?>
Does any one of you know how to change encoding in SSIS package by replacing first line of XML document? Or maybe you know some other, better solutions?
As an example we can use just basic XML document with UTF-8 encoding (file attached)
<?xml version="1.0"?>
<MyNode>
<ChildNode>TEST</ChildNode>
</MyNode>
Can anyone help?
Can i provide anything to help you helping me?
Regards
July 14, 2021 at 7:41 am
I know nothing about this specific problem.
But adding a Script Task to edit and save the file before onward processing should be straightforward. Can you write a little C#?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 14, 2021 at 12:27 pm
I can't unfortunately.
So, script task is the way to go and C#.
I see what i can do.
Thank you!
July 14, 2021 at 12:53 pm
This could also be done in Posh.
Have a go and see how you get on. Feel free to post back ... if you cannot get this working, I will put something together for you.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 23, 2021 at 9:50 am
In the end i used powershell script like below to change Encoding to ASCII and that did the trick
Get-ChildItem "PathToYourFolder" -Filter *.xml |
ForEach-Object{
$file=Get-Content $_.FullName
$file | Set-Content -Encoding Ascii $_.FullName
}
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply