473,585 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7968
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.CreateNavig ator(); //doc is the XmlDocument you
got from dataset1.GetXml ()

XmlResolver xmlResolver = null;

MemoryStream ms = new MemoryStream();

XsltArgumentLis t args = new XsltArgumentLis t();

NameTable nt = new NameTable();

XmlNamespaceMan ager nsm = new XmlNamespaceMan ager(nt);

XmlValidatingRe ader xmlR = new XmlValidatingRe ader([your XSLT code here],
XmlNodeType.Doc ument, new XmlParserContex t(null, nsm, null,XmlSpace.N one));
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.ReadXm l(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*********@ho tmail.com> schrieb im Newsbeitrag
news:uT******** ******@TK2MSFTN GP10.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*******@icom cept.com> wrote in message
news:u7******** ******@TK2MSFTN GP10.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.CreateNavig ator(); //doc is the XmlDocument you got from dataset1.GetXml ()

XmlResolver xmlResolver = null;

MemoryStream ms = new MemoryStream();

XsltArgumentLis t args = new XsltArgumentLis t();

NameTable nt = new NameTable();

XmlNamespaceMan ager nsm = new XmlNamespaceMan ager(nt);

XmlValidatingRe ader xmlR = new XmlValidatingRe ader([your XSLT code here],
XmlNodeType.Doc ument, new XmlParserContex t(null, nsm, null,XmlSpace.N one));

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.ReadXm l(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*********@ho tmail.com> schrieb im Newsbeitrag
news:uT******** ******@TK2MSFTN GP10.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
29478
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" keyword? if it is, i know the history that is without "export" keyword of C++ compilers with five years (sorry about my poor english :-) ), in five years...
205
10516
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
1841
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 file or what type? There are many selections when you choose file type. When do you need to export data? How often? Do you use DTS rather than...
6
17010
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 (faster). Is there any workaround or tuning config that is available? Your help would be highly appreciated. maricel
5
10562
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 of ixf messages MKPF.msg select * from mkpf" on the same 3581, and this table is only 5GB, but the export used 4 hours. What's the diffirent between...
5
11018
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 setting stDataSource and stFileName to the desired values. Most of the time it works, but occasionally, typically as code changes are being made to...
7
14353
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 display the graph but it is not possible to send query parameters to an OLE graph on a report (or programatically change any properties of an OLE...
1
5238
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 "/home/db2as/sqllib/bluee_tables1/DBCHECK.ixf". if it is beginning to export and
5
3410
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 drive to then later be FTPd to a server. the file format should be "TITLE.yyyymmdd" where yymmdd is the date code for when the files are created. ...
8
18763
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", "C:\qryFFRDeFile.txt", True Access asks for a specification name, now here lies the challenge, how do I create an export specification I have...
0
7900
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8192
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5705
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3828
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1167
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.