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 8729329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:48:53+00:00 2026-06-13T08:48:53+00:00

I need to pull data from a database and create an xml file via

  • 0

I need to pull data from a database and create an xml file via ssis. So far, I’ve created a script that can successfully create an xml file (using XmlTextWriter), listing all necessary data, however, they also want the schema listed within the file as well and I’m not sure how to do it.

Here’s my current code to create my xml file (using a Script Component in my data flow):

StreamWriter sw;
XmlTextWriter xWriter;
String rowName;
String collectionName;
private int[] columnNames;    
public override void PreExecute()
{


    rowName = "Responses";
    collectionName = "NewDataSet";
    String fileName = Variables.FullFileName;        
    xWriter = new XmlTextWriter(fileName, null);
    xWriter.WriteStartDocument();
    xWriter.WriteStartElement(collectionName);
}

public override void PostExecute()
{        

    xWriter.WriteEndElement();
    xWriter.WriteEndDocument();
    xWriter.Close();
}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    Type rowType = Row.GetType();
    PropertyInfo columnValue;

    xWriter.WriteStartElement(rowName);
    foreach (IDTSInputColumn100 column in this.ComponentMetaData.InputCollection[0].InputColumnCollection)
    {
        columnValue = rowType.GetProperty(column.Name);
        xWriter.WriteStartElement(column.Name);

        Object value = columnValue.GetValue(Row, null);
        if(value != null)
        {
            xWriter.WriteValue(value.ToString());

        }

        xWriter.WriteEndElement();
    }      
}

How can I add schema info to this? I’ve seen tutorials for “WriteXmlSchema”, but this seems to only work with a dataset (which I’m not using).

I really appreciate any help you can provide.

  • 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-06-13T08:48:54+00:00Added an answer on June 13, 2026 at 8:48 am

    If you just need to reference an existing schema within the xml document, it’s just an attribute in the root element. See this tutorial re XML schemas. In the example on that page, to write the reference to the schema, after
    xWriter.WriteStartElement(collectionName);
    add

    xWriter.WriteAttributeString("xsi:schemalocation", "http://www.w3schools.com note.xsd") 
    

    If you need to create the xsd schema document there are various ways to do this. I suggest googling “create xsd from …”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an old Access 2000 database that we need to pull data from
I need to pull data from one SQL 2005 Express database to another and
We need to create a custom formula for users to pull data from our
I have two different tables from which I need to pull data blogs which
I need to pull a list of items from a MySQL database and then
From a string, I need to pull out groups that match a given pattern.
I created a C#.net app that uses dates from a SQL Server 2008 database
Here's what I'm trying to do. I'm trying to pull data from a database
I need to pull a large amount of data from various tables across a
I have a series of values in a database that I need to pull

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.