XmlWriter in C#
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: XmlWriter in C#

  1. #1
    Join Date
    Mar 2010
    Posts
    6

    XmlWriter in C#

    I am working on a project in C# that will get a recordset returned from SqlServer and I need to write out a file in XML using a XmlWriter. My problem is trying to figure out how to write the Xml file to match the schema. Ive looked the web over & this seems to be an unusual thing to do.Can anyone give me some ideas on doing this. Ive just started learning XML and I think I have a decent understanding on getting the writer to work, but this problem of matching the schema is throwing me.

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: XmlWriter in C#

    Quote Originally Posted by mrkensr
    My problem is trying to figure out how to write the Xml file to match the schema
    What "schema"? I assume you are able to retrieve the data from the database one way or another. The next step is to generate the Xml. If you have to match a particular schema why not generate xml that matches that schema? Forgive me for asking but do you understand what a schema is? An xml schema might specify that the root element is 'MusicRecordCollection' which happens to be a sequence of o or more 'MusicRecord' which in turn defines attributes 'Title' and 'Artist'. So if you were querying a record database you would get the data and generate the xml. eg..

    Quote Originally Posted by mrkensr
    Ive looked the web over & this seems to be an unusual thing to do.Can anyone give me some ideas on doing this.
    This is possible. However given your level of experience (in XML and related subjects) it is probably more likely that your search could have been more effective. There are many ways to accomplish what I think you want. Some of the methods would not necessarily come up in xml schema specific search (e.g. example I mentioned earlier). You can also have a look at XSLT which is used to transform an XML document from one structure to another (i.e matching a target schema). You can apply an XSL transform through C# (just have a look at the documentation or google it).

    Perhaps you need to clarify what problem you are actually facing. You could make things clearer by showing some of the code that you've got and where you would like to intergrate this kind of functionality.
    Last edited by nelo; March 6th, 2010 at 05:49 PM. Reason: Clarification

  3. #3
    Join Date
    Mar 2010
    Posts
    6

    Re: XmlWriter in C#

    Thanks for getting back so quick. Maybe I didnt explain well enough...Im will be calling a stored procedure to get data. My program needs to produce an xml file from the returned recordset. That file needs to match the layout that I am getting from the client. The idea for this program is to be flexible so that when a client wants a xml file generated, they only need to specify what data they need & what layout they want the file to match. Right now I have a VB6 program that will generate Excel files and text files.

  4. #4
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: XmlWriter in C#

    Quote Originally Posted by mrkensr View Post
    Thanks for getting back so quick. Maybe I didnt explain well enough...Im will be calling a stored procedure to get data. My program needs to produce an xml file from the returned recordset. That file needs to match the layout that I am getting from the client. The idea for this program is to be flexible so that when a client wants a xml file generated, they only need to specify what data they need & what layout they want the file to match. Right now I have a VB6 program that will generate Excel files and text files.
    Well in my humble opinion you will have to write some code each time the client wants some thing different. My suggestion to you would be to get all the data they could possibly want. And when the want different portions of it you can apply an XSL transform to output an xml with the layout and data the client wants to see.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center