473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XML Export-Import

Hello.

What is the optimal way to manualy import/export data from/to XML file
to/form my DataSet?

What I wnat:
1. To add some data (records) from XML file to may dataset.
2.. To add some data (records) from dataset to may XML file.

For example:

Table structure:
ID int Primary Key
FirstName VarChar (15)
LastName VarChar (15)
Age int

XML file structure:
<Pesrons>
<ID> </ID>
<FirstName> </FirstName>
<LastName> </LastName>
<Age> </Age>
</Pesrons>

If it's poseble show me little example or some demo please.
Nov 16 '05 #1
2 7950
Hi David,

I'd get the dataset's XML with

string xml = dataset1.GetXml();
and transform that xml into my desired output using XSLT. This way you can
always change your putput without having to change your program's code.
Beside that, this way you can easily ensures that your XML is valid.

To use XSLT youe have to do something like this:

XPathNavigator xpath = doc.CreateNavigator(); //doc is the XmlDocument you
got from dataset1.GetXml()

XmlResolver xmlResolver = null;

MemoryStream ms = new MemoryStream();

XsltArgumentList args = new XsltArgumentList();

NameTable nt = new NameTable();

XmlNamespaceManager nsm = new XmlNamespaceManager(nt);

XmlValidatingReader xmlR = new XmlValidatingReader([your XSLT code here],
XmlNodeType.Document, new XmlParserContext(null, nsm, null,XmlSpace.None));
XslTransform xslt = new XslTransform();

xslt.Load(xmlR, null, null);

xslt.Transform(xpath, args, ms, xmlResolver);

After that ms carries the output XML you wanted to get. You could save it
into a file or whatever.

To load XML into a dataset you have to do the same, but the input is the XML
you can load from wherever and after transforming it using XSLT you can use

dataset1.ReadXml(ms);

This is the way I'd preferr as the most professional. Hope this helps.

For a brief intruduction into XSLT, try
http://www.xml.com/pub/a/2000/08/holman/.

Regards,

Munir Husseini

iCOMcept GmbH

www.icomcept.com

"Ghost" <da*********@hotmail.com> schrieb im Newsbeitrag
news:uT**************@TK2MSFTNGP10.phx.gbl...
Hello.

What is the optimal way to manualy import/export data from/to XML file
to/form my DataSet?

What I wnat:
1. To add some data (records) from XML file to may dataset.
2.. To add some data (records) from dataset to may XML file.

For example:

Table structure:
ID int Primary Key
FirstName VarChar (15)
LastName VarChar (15)
Age int

XML file structure:
<Pesrons>
<ID> </ID>
<FirstName> </FirstName>
<LastName> </LastName>
<Age> </Age>
</Pesrons>

If it's poseble show me little example or some demo please.

Nov 16 '05 #2
Oh, it's great!
but can you provide me more simple exanple without XSLT?

"Munir Husseini" <mh*******@icomcept.com> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Hi David,

I'd get the dataset's XML with

string xml = dataset1.GetXml();
and transform that xml into my desired output using XSLT. This way you can
always change your putput without having to change your program's code.
Beside that, this way you can easily ensures that your XML is valid.

To use XSLT youe have to do something like this:

XPathNavigator xpath = doc.CreateNavigator(); //doc is the XmlDocument you got from dataset1.GetXml()

XmlResolver xmlResolver = null;

MemoryStream ms = new MemoryStream();

XsltArgumentList args = new XsltArgumentList();

NameTable nt = new NameTable();

XmlNamespaceManager nsm = new XmlNamespaceManager(nt);

XmlValidatingReader xmlR = new XmlValidatingReader([your XSLT code here],
XmlNodeType.Document, new XmlParserContext(null, nsm, null,XmlSpace.None));

XslTransform xslt = new XslTransform();

xslt.Load(xmlR, null, null);

xslt.Transform(xpath, args, ms, xmlResolver);

After that ms carries the output XML you wanted to get. You could save it
into a file or whatever.

To load XML into a dataset you have to do the same, but the input is the XML you can load from wherever and after transforming it using XSLT you can use
dataset1.ReadXml(ms);

This is the way I'd preferr as the most professional. Hope this helps.

For a brief intruduction into XSLT, try
http://www.xml.com/pub/a/2000/08/holman/.

Regards,

Munir Husseini

iCOMcept GmbH

www.icomcept.com

"Ghost" <da*********@hotmail.com> schrieb im Newsbeitrag
news:uT**************@TK2MSFTNGP10.phx.gbl...
Hello.

What is the optimal way to manualy import/export data from/to XML file
to/form my DataSet?

What I wnat:
1. To add some data (records) from XML file to may dataset.
2.. To add some data (records) from dataset to may XML file.

For example:

Table structure:
ID int Primary Key
FirstName VarChar (15)
LastName VarChar (15)
Age int

XML file structure:
<Pesrons>
<ID> </ID>
<FirstName> </FirstName>
<LastName> </LastName>
<Age> </Age>
</Pesrons>

If it's poseble show me little example or some demo please.


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: DarkSpy | last post by:
many c++ compilers including "gcc" have not implemented the "export" keyword, but the comeau compilers made it (just i knew). i want to know about: is it too difficult to implement "export"...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
1
by: Do Park via SQLMonster.com | last post by:
Hello all, I don?t often export data from a table. I am wondering how you export data from a table. I?d like to know how you export in real world. Do you export data from a table to a flat...
6
by: maricel | last post by:
Is there anybody out there who have any idea why EXPORT is relatively slower when putting the output file on a network drive - map drive from onother PC compared to putting it on my local PC drive...
5
by: David | last post by:
I am a little confused by DB2 Backup and Export. I used "db2 backup db QAS to /dev/rmt0" backuping 650GB database to a IBM LTO 3581 (1 drive) only 11 hours. But I used "db2 export to /dev/rmt0...
5
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
7
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to...
1
by: chaitu | last post by:
Hi, Can anybody tell me what the error code for Export is. Like i get the message SQL3104N The Export utility is beginning to export data to file...
5
by: JHNielson | last post by:
I have a somewhat simple question, but have been baffled by it for a while, and now I'm on a tight deadline - have to get it done within 24 hours. I am trying to export a set of files to my hard...
8
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile",...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.