Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:23:21+00:00 2026-05-23T13:23:21+00:00

Using .NET (in an SSIS package): I’ve got an XML string in memory which

  • 0

Using .NET (in an SSIS package):

I’ve got an XML string in memory which I need to save to a varbinary column in Sql Server, as an XML file.

It seems like I should be able to avoid actually saving a .xml file to disk, and do all of this in memory, but I’m not sure how. My initial thought was to use the File class in System.IO, but this class seems to require a file on disk.

Is there a way in memory to convert the XML string to its bytes and save those to the DB?

Thanks.

(I’m coding in VB but naturally C# examples are fine too).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:23:22+00:00Added an answer on May 23, 2026 at 1:23 pm

    I would expect that to work fine as a byte[]; so all you need to do is serialize the string. If I make an assumption that the xml is tagged as UTF8 internally (or not tagged at all), then perhaps:

    var data = Encoding.UTF8.GetBytes(yourXmlString);
    

    However, note that if your xml is tagged internally with a different encoding to UTF8, the actual encoding should ideally match (otherwise: bad things).

    Of course, if you are creating the xml, then you can write it directly to binary and select the encoding at the same time. You can do this by passing a Stream and an Encoding to XmlWriter:

    byte[] bytes;
    using (var ms = new MemoryStream())
    {
        using(var xw = XmlWriter.Create(ms, new XmlWriterSettings { Encoding = Encoding.UTF8 }))
        {
            // write to xw, directly or indirectly
        }
        bytes = ms.ToArray();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an interesting challenge with SSIS. Using a for-each file enumerator, I need
Using .NET, I have a requirement in which I need to execute a process
Using .net 2.0 . I want to display a column in a DataGridView as
I have an SSIS package with a Data Flow that takes an ADO.NET data
Using .Net, I need to generate a response based on only the checkboxes on
Using .Net how can I check which users in our domain have resources (files,
I'm getting this error when running an SSIS package through SQL Agent Failed to
Using .NET string formatting you can plug the same value into a format string
Using .Net 4.0. I have a some code which tries to open a connection
when using .net classes, there are cases when we don't need parenthesis to pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.