Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2003

Tip: Looking for answers? Try searching our database.

XML encoding problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DelBoy - 22 Oct 2003 00:26 GMT
I'm tryin to read an XML file created by Oracle into SQL Server.

Oracle creates a file using the "WE8ISO8859P1" character set : ISO-8859-1.
I need to read the file using UTF-8.

The code I'm using to read the file is:

   objDSXML.ReadXml(sFilename)

where sFileName is the full path of the file.

I get the error : Invalid byte was found at byte index XXXX

Is there some way I can convert the file in dotNet without using the
advanced save functionality.
Need a way to convert it using code, as this has to be automatic.

Any ideas would be warmly welcomed,
thanks.
Christoph Schittko [MVP] - 22 Oct 2003 04:10 GMT
Can you read the XML you get from Oracle using an XmlTextReader and then
write them out with an XmlTextWriter that's writing to a StringWriter?

Signature

HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

> I'm tryin to read an XML file created by Oracle into SQL Server.
>
[quoted text clipped - 15 lines]
> Any ideas would be warmly welcomed,
> thanks.
Chris Lovett - 22 Oct 2003 06:57 GMT
Try the following:

using System.Text;
using System.IO;

Encoding enc = Encoding.GetEncoding("ISO-8859-1");
StreamReader sr = new StreamReader(path, enc, false);
try {
   ds.ReadXml(sr);
} finally {
   sr.Close();
}

> I'm tryin to read an XML file created by Oracle into SQL Server.
>
[quoted text clipped - 15 lines]
> Any ideas would be warmly welcomed,
> thanks.
DelBoy - 22 Oct 2003 18:11 GMT
Thank you very much, that works great. It's slower, but who cares.
Here's the VB version of the code for others, should they require it.

***
   Dim objDSXML As New DataSet()
   Dim enc As Encoding
   Dim sr As StreamReader

   enc = Encoding.GetEncoding("ISO-8859-1")
   sr = New StreamReader(sFilename, enc, False)
   objDSXML.ReadXml(sr)
***
thanks again.

> Try the following:
>
[quoted text clipped - 28 lines]
> > Any ideas would be warmly welcomed,
> > thanks.
Chris Lovett - 23 Oct 2003 05:50 GMT
It shouldn't be any slower.  Did you measure a difference?

> Thank you very much, that works great. It's slower, but who cares.
> Here's the VB version of the code for others, should they require it.
[quoted text clipped - 43 lines]
> > > Any ideas would be warmly welcomed,
> > > thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.