DataSet to XML

I have data coming from SQL Server and need to write out some XML. I
have a schema(xsd) for this XML file.  Right now I am bringing in the
DataSet and writing out the elements and attributes myself using
xmltextwriter to match schema without really using the xsd at the time
of writing.

The file I create validates but I was wondering is there a better way?
I see things like inferschema method off of dataset, can this be used?
How do you map columns in a dataset with elements and attributes in
the schema? I know dataset.WriteXmL will write XML but that match my
schema. Appreciate any help!

Thanks,
Joe
0
7/12/2004 6:32:52 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
745 Views

Similar Articles

[PageSpeed] 32

Hi Joe,

"Joe98765" <joesmith98765@hotmail.com> wrote in message 
news:4490752b.0407121032.4e8c0a01@posting.google.com...
>I have data coming from SQL Server and need to write out some XML. I
> have a schema(xsd) for this XML file.  Right now I am bringing in the
> DataSet and writing out the elements and attributes myself using
> xmltextwriter to match schema without really using the xsd at the time
> of writing.
>
> The file I create validates but I was wondering is there a better way?
> I see things like inferschema method off of dataset, can this be used?
> How do you map columns in a dataset with elements and attributes in
> the schema? I know dataset.WriteXmL will write XML but that match my
> schema. Appreciate any help!

I find it a bit hard to grasp your problem - you want to write out the 
DataSet as
xml - and you want it to validate against your schema - but you don't want 
to
use the dataset.WriteXml() that actually writes out conforming xml !?

Is it speed/other performance issues you're troubling with?

-- 
Lars Wilhelmsen
http://www.sral.org/
Software Engineer
Teleplan A/S, Norway 


0
larswil (1)
7/12/2004 6:44:35 PM
"Lars Wilhelmsen" <larswil@NOSPAM.ifi.uio.no> wrote in message news:<ufbUIBEaEHA.1644@tk2msftngp13.phx.gbl>...
> Hi Joe,
> 
> "Joe98765" <joesmith98765@hotmail.com> wrote in message 
> news:4490752b.0407121032.4e8c0a01@posting.google.com...
> >I have data coming from SQL Server and need to write out some XML. I
> > have a schema(xsd) for this XML file.  Right now I am bringing in the
> > DataSet and writing out the elements and attributes myself using
> > xmltextwriter to match schema without really using the xsd at the time
> > of writing.
> >
> > The file I create validates but I was wondering is there a better way?
> > I see things like inferschema method off of dataset, can this be used?
> > How do you map columns in a dataset with elements and attributes in
> > the schema? I know dataset.WriteXmL will write XML but that match my
> > schema. Appreciate any help!
> 
> I find it a bit hard to grasp your problem - you want to write out the 
> DataSet as
> xml - and you want it to validate against your schema - but you don't want 
> to
> use the dataset.WriteXml() that actually writes out conforming xml !?
> 
> Is it speed/other performance issues you're troubling with?


Sorry, let me clarify...as I mistyped "I know dataset.WriteXML will
write XML but that DOESN'T match my schema".

dataset.writexml would be great...but how do you get it to write xml
based on a existing schema? Is there a way to associate an existing
schema and map my columns in the dataset to elements/attributes and
then call the WriteXml method?
0
7/13/2004 12:11:06 AM
>
> Sorry, let me clarify...as I mistyped "I know dataset.WriteXML will
> write XML but that DOESN'T match my schema".
>
> dataset.writexml would be great...but how do you get it to write xml
> based on a existing schema? Is there a way to associate an existing
> schema and map my columns in the dataset to elements/attributes and
> then call the WriteXml method?

I think you are not framing your question quite right. Validation based on a
schema happens during the reading, not writing.

A truely wonderful free reference is the sample chapter from Bob
Beauchemin's
Essential ADO.Net

http://www.awprofessional.com/bookstore/product.asp?isbn=0201758660


0
mbosley (4)
7/13/2004 3:52:25 AM
Reply:

Similar Artilces:

Access & XML
Anyone know of a decent Training Site for using XML w/ Access? A Client is willing (pay the cost) to send me to XML Training. I would be using SQL Server & Cognos (perhaps Oracle) XML Tables into Access. Then automating Reports to Excel. TIA - Bob ...

XML
This is an honest question, no sarcasm intended. I'm really curious, what -is- the big deal about XML? I'm heaing all sorts of things such as an open standard that can be read across all platforms, etc. But really, my colleagues are insisting that we transfer large chunks of data using XML. There is so much overhead compared to a simple flat file using csv or fixed length fields. A 10k record file is ending up being 3 times that of what it would be if it were fixed length. Even ini files still have their appeal to me over what I've seen from XML. Maybe I'm missing ...

Include XML data in dll
I'm writing an application where I need to store a small amount of xml data in a relatively secure way - I don't want it just sitting out there in a separate file; I'd rather have it compiled into the dll I'll produce. What's the best way to achieve this? - Turtle You can put it in resource. If you like, you can encrypt the resource. To add a resource to VS project, add the file to the project in the olution Explorer, then set the properties of the file to be an embedded resource. Paul "MacDermott" <macdermott@mindspring.com> wrote in message ...

SSRS Linking Dataset
I have converted some reports in Access to SQL 2008 Reporting Services. However, some of the reports have subreports in them and they look fine in design but when I try to run the report previewing it from VS 2008 I get the main report but not the subreport. Apparently, the subreport is not tied to a Dataset even though the dataset shows up in the Report Data section on left side of VStudio. I cannot find anywhere in proerties to attach a dataset to the subreport. Also, how do I "link" the subreport to the main report to get only the correct records in the subrepo...

How to RANDOMLY split a whole dataset into two sub-dataset? #3
Hi, At your possible convenience, might anyone please kindly answer my question? How to RANDOMLY split a whole dataset (n=2000) into two sub dataset (n=1000, n=1000) in SPSS or Excel? Thank you very much. Please take care Caroline You have two answers in your other posting. Pete On Jul 17, 6:33 am, zencaroline <zencarol...@gmail.com> wrote: > Hi, > > At your possible convenience, might anyone please kindly answer my > question? > > How to RANDOMLY split a whole dataset (n=2000) into two sub > dataset (n=1000, n=1000) in SPSS o...

Automagically create database schema from XML dataset
Hello. I am trying to create a database from an XML file. I am able to create a dataset from the XML doc, but how can I create a database schema from the dataset and populate the database? Or is this even possible using VS.NET 2003? Part of the XML file follows. Thanks for any help. Steven VS.NET 2003 and C# newbie! ----- Part of the XML (one full record across several tables) -------- <!DOCTYPE PubmedArticleSet...> - <PubmedArticleSet> - <PubmedArticle> - <MedlineCitation Owner="NLM" Status="Completed"><PMID>11604973</PMID> - &l...

Creating typed dataset from an industry standard schema
Has anyone run into problems creating typed datasets from complex schemas? I am attempting to create a Typed Dataset in Visual Studio .Net from a .xsd schema file for a industry standard web service. I have run the schema through XML Spy and validated it with no errors, but when attempting to generate a dataset, I keeping getting a 'undefined data type' error. The schema is quite large so I don't know if that is causing the problem or if it is just something odd about .Net's parser. Here is the section of the schema causing the problem. There are only two spots where the...

Need help designing XML Dataset
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I tried doing this without any help, but i'm getting nowhere. I want to create an XML schema (XSD) for a dataset/datatable using the XML designer. I want to be able to have a table for each trip. The trip will contain a trip no, date etc. But i also want it to have a State element like "PA, NJ, MD" for each state with miles traveled for each state. I don't want to enter 50 elements name MilesPA, MilesNJ, MilesMD etc. Is t...

why doesn't this modification to XML receipt work?
how can i modify the fullpage.xml file so that if the sale is charged to the customer's store account, the title of the receipt is 'SALES INVOICE' - otherwise we want the title to be 'SALES RECEIPT'...i tried modifying the file as shown below without success: <IF><CONDITION> Tender.Descriptor.TenderType = 4 </CONDITION> <THEN> <TEXT> "SALES INVOICE" </TEXT> </THEN> <ELSE> <TEXT> "SALES RECEIPT" </TEXT> </ELSE> <...

eConnect
In eConnect, I tried adding an additional XML node to the existing XML schema. I like to have these to be added in line item level. When I tried this, it worked fine when I added a node (along with a procedure in db) at the header level. But it fails to perform at line item level. Please help me with the steps to achieve the same. Thanks in advance. ...

XML question #2
Hello, I am using VB/ASP.net 2005. When I click submit it refreshes the page without entering the data from all the text boxes and not entering in the Game1.xml. here is the asp.vb code Imports System.Xml Partial Class _game1 Inherits Web.UI.Page ............... Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim xDoc As New XmlDocument xDoc.Load(Request.MapPath("game1.xml")) Dim newComment As XmlDocumentFragment = xDoc.CreateDocumentFragment() newComment.InnerXml = "<Game>" + _ "<Wname>&...

GetXml from DataSet
Hello, I transfer data from a dataset to an XML-document by using the GetXml-method in VB.NET. I noticed, that for datafields, which are empty (have no content) in the dataset, no elements are created in the XML-document. How can I force to generate elements (with no content) for this kind of datafields ? Thanks em Check out http://www.topxml.com/sqlxml/default.asp It has some excellent information on this. Regards Keith Chadwick "em" <nix@nix.nix> wrote in message news:018f01c3ba37$e4b0b760$a001280a@phx.gbl... > Hello, > I transfer data from a dataset to an XML...

where does Microsoft.Xml.Xquery live?
where does Microsoft.Xml.Xquery live? where does Microsoft.Xml.Xquery live? all i can find is a copy of it in the sample project: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvsdev05/html/vs05c5.asp but would like to know where Microsoft.Xml.Xquery should be obtained. There is no such thing -- Stan Kitsis Program Manager, XML Technologies Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm "D...

Passing Parameter to Transform of XML to XML
The following transformation puzzles me when trying to transform XML to XML. I get an exception "THE EXPRESSION PASSED TO THIS METHOD SHOULD RESULT IN A NODESET" at the last line "xmlDoc.Load(xr)" when I run the code. I previously tried it all without a parameter and hard-coded the value into the 'apply-templates' statement and the tranform produced the result that I expected but when I inset the parameter I get the exception. I would appreciate it if someone could look over the code and identify which part of the code causes the fault I use VB.NET 2003 and .NE...

Problem with XML Namespace
Hello, As a VB6 programmer, I'm quite a newbee in .NET. I'm working with Visual Studio .NET 2005 Beta2 and try write a class that reads an online xml document. Let's say, something you would do with XmlHttp in VB6. My problem is, that my GUI does not recornize the System.xml namespace. I get this error: "namespace or type specified in the imports 'System.xml' cannot be found" Why do I get this error? Thanks, Ramon. Ramon wrote: > As a VB6 programmer, I'm quite a newbee in .NET. > > I'm working with Visual Studio .NET 2005 Beta2 and try...

xml and dataset
I want to take a dataset and save the data as an xml document. I know how to do this, but I need the xml to be formatted in a certain way. What are my options? I have thought about using a stylesheet to format from xml to xml. I can create an xsd, but that does not seem to save the dataset the way I need it. It just adds the schema to the top, but does not put the xml in a hierarchical format. TypedDataSet.WriteXml("C:\Test.xml", XmlWriteMode.WriteSchema) Hi Ken, You can do it using the XMLdoc. Because I do not know what you are reformating it is difficult to say more. Cor...

experts: structure of dataset xml
hello, i have a problem, i wonder if anyone can help... i am retrieving records from an access table using a dataset and want the data to be returned in xml, so i am using the dataset.GetXml() method. lets say, for example, that the xml is in the following format: <Users> <User> <UserId>1</UserId> <Username>robert</Username> <Password>friend</Password> </User> <User> <UserId>2</UserId> <Username>natasha</Username> <Password>sunny</Password...

XML discount print issue
Hi all, I have a issue with printing discounts on receipts. First of all, I did a lot of RMS XML programming for customers, so I think I know what i'm talking about. But I cannot figure out the following: The price and extended price printed on receipts are the actual prices customers have to pay. Now I have one customer who wanted to always print the full price on each line, without the discounts instead of the discounted price. That can easily be done by changing the Entry.Price to Entry.FullPrice. So far so good. But, now they want also the following. If they change a price at...

XML that one of its elements has line break.
Hello, I am using access as my database, One of my columns is memo field, so it has sevral line at its context. Can I convert line break to something readable in XML ? Is there any function for that ? Thanks :) Same thing. Any character, be it ascii or unicode has it's place or number. If Access bitches, it is Access and not Calculus. "Mr. x" <a@b.com> wrote in message news:uaYLyYxeDHA.4024@TK2MSFTNGP11.phx.gbl... > Hello, > I am using access as my database, > One of my columns is memo field, so it has sevral line at its context. > Can I convert line b...

How do I read an XmlDocument object into a dataset???
I need to read an in-memory instance of a loaded XmlDocument into a referenced DataSet. What's the best way to do this? I've tried "myDataSet.ReadXml(myXmlDocument)" but it won't compile. I get a compile error because the XmlDocument type isn't accepted by the ReadXml() method. I need to figure this out! Thanks, ~A~ Blah - nevermind. I don't need the xmldocument - I just feed the xml stream straight into the dataset. Thanks, ~A~ "Kewlpack" wrote: > I need to read an in-memory instance of a loaded XmlDocument into a > referenced DataSet....

Write dataset to xml and back again to dataset?
Before a delete on any table, I would like to write the contents of the soon-to-be-deleted row to that application's single "graveyard" table (alternate: or document as coded below). SQL Server 2005 solution: I would store the tablename, today's date, username, and the key column values of the soon-to-be deleted row as the composite key of the new graveyard table row. The soon-to-be-deleted row's data would be stored in a single xml-type column. XML File solution: composite key from above would be the name of a filename.xml file. The data from the soon-to-be-deleted...

Can we set the UI color scheme via VB[A} or XML?
Does anyone know a way to set the color scheme for the UI, using VB[A} or XML? Can this even be done? Thanks -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc Sorry for not qualifying the Excel version. It's v12 or higher. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc ...

XML format enforcement
I wish to write some kind of XML format enforcer like DTD, XSD or other that can do the following: (1) Any element and node must have Type attribute that can be read as data type by the parser. (1) Any element and node may have (optional) four more attributes. I XML enforcer should allow any tree structure and any number of nodes in any tree. Does anyone can tell how it's possible? Any example will be most appreciated. -- Thanks Sharon Sharon wrote: > I wish to write some kind of XML format enforcer like DTD, XSD or other that > can do the following: > (1) Any element a...

string and xml useage
Am I using strings properly in the code below? The code is working but not sure if my conversions are normal / standard / acceptable. CComPtr <IXMLDOMDocument2> m_pDocument; hr = m_pDocument.CoCreateInstance(CLSID_DOMDocument2); DEBUG_HR(hr); .... add elements to m_pDocument ... // create indented xml CComBSTR bRootXml; CString rootXml; hr = m_pDocument->get_xml(&bRootXml.m_str); DEBUG_HR(hr); rootXml = bRootXml; // add cariage returns between tags rootXml.Replace("><", ">\n<"); TRACE("rootXml:\n%s...

TLB or IDL to XML
Hi all! Can I convert typelib to XML. I found somthing to convert IDL to XSD? Are there other posibility? Thanks for response! ...