473,699 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml-export in vb.net

hello NG

i try to create a little generic vb.net function for exporting access-tables
to
xml-files.
---===>>> CUT IN <<<===---
Function fncXmlExport(By Val strDBpath As String, ByVal strTableName As
String, ByVal strXmlFileName As String)
Dim objDataSet As New System.Data.Dat aSet
Dim objXmlDocument As New System.Xml.XmlD ocument
Dim objCmd As System.Data.Ole Db.OleDbDataAda pter
Dim objCon As System.Data.Ole Db.OleDbConnect ion
Dim strCon As String
strCon = "provider=Micro soft.Jet.OLEDB. 4.0; data source=" & strDBpath
objCon = New System.Data.Ole Db.OleDbConnect ion(strCon)
objCmd = New System.Data.Ole Db.OleDbDataAda pter("select * from " &
strTableName, objCon)
objCmd.Fill(obj DataSet)
objCon.Close()
objXmlDocument. LoadXml(objData Set.GetXml())
objXmlDocument. Save(strXmlFile Name)
End Function
---===>>> CUT OUT <<<====---

so far, so good, the file is being created, but i am missing this line
--->>> CUT IN <<<---
<?xml version="1.0" encoding="UTF-8"?>
--->>> CUT OUT <<<---
at the beginning of the file - and therefore it is not recognized as a valid
xml-file by other applications.
also a little problem, the file starts like this:
--->>> CUT IN <<<---
<NewDataSet>
<Table>
<IDAbschluss>39 5</IDAbschluss>
<strAnrede>Herr </strAnrede>
--->>> CUT OUT <<<---

how can i change "<NewDataSe t>" and "<Table>"?
tnx for a short feedback!
greetz, curtis

Nov 12 '05 #1
3 8375
OK, since you asked for it, I'll make it short:

Changing the serialization format of the DataSet:

Dim objDataSet As New System.Data.Dat aSet( "MyDataSetN ame" )
....
objCmd.Fill(obj DataSet, "MyTableNam e")
and the missing document declaration should not be a problem. Are you having
a problem with a specific app?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"curtis m. west" <cu****@gr8.c h> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
hello NG

i try to create a little generic vb.net function for exporting access-tables to
xml-files.
---===>>> CUT IN <<<===---
Function fncXmlExport(By Val strDBpath As String, ByVal strTableName As
String, ByVal strXmlFileName As String)
Dim objDataSet As New System.Data.Dat aSet
Dim objXmlDocument As New System.Xml.XmlD ocument
Dim objCmd As System.Data.Ole Db.OleDbDataAda pter
Dim objCon As System.Data.Ole Db.OleDbConnect ion
Dim strCon As String
strCon = "provider=Micro soft.Jet.OLEDB. 4.0; data source=" & strDBpath
objCon = New System.Data.Ole Db.OleDbConnect ion(strCon)
objCmd = New System.Data.Ole Db.OleDbDataAda pter("select * from " &
strTableName, objCon)
objCmd.Fill(obj DataSet)
objCon.Close()
objXmlDocument. LoadXml(objData Set.GetXml())
objXmlDocument. Save(strXmlFile Name)
End Function
---===>>> CUT OUT <<<====---

so far, so good, the file is being created, but i am missing this line
--->>> CUT IN <<<---
<?xml version="1.0" encoding="UTF-8"?>
--->>> CUT OUT <<<---
at the beginning of the file - and therefore it is not recognized as a valid xml-file by other applications.
also a little problem, the file starts like this:
--->>> CUT IN <<<---
<NewDataSet>
<Table>
<IDAbschluss>39 5</IDAbschluss>
<strAnrede>Herr </strAnrede>
--->>> CUT OUT <<<---

how can i change "<NewDataSe t>" and "<Table>"?
tnx for a short feedback!
greetz, curtis

Nov 12 '05 #2
tnx for your anwer - helped very much!
i'm starting working my way into the DS-class (as i only used
ADODB-recordsets yet)...
so my path got to:
--->>> CUT IN <<<---
objDataSet.Writ eXml("d:\test.x ml", XmlWriteMode.Wr iteSchema)
or
objDataSet.Writ eXmlSchema("d:\ test.xsd")
objDataSet.Writ eXml("d:\test.x ml", XmlWriteMode.Ig noreSchema)
--->>> CUT OUT <<<---
what seems to be the better way for my needs. (also includes the document
declaration)

but still the some problems: there are phone-numbers in the table with
leading zeros (079######)
-if i use ".ignoreschema" , i miss the leasing zeros, as the field will be
recognized as a number-field.
-if i use ".writesche ma", it works fine while importing into ms-access...
but ms-excel does not recognize the inline-schema...
-if i use ".ignoresch ema" and write a separate-schema-file (.writexmlschem a)
excel does not "link the two files together"
(is there a way to include a path to the schemafile in the datafile?)

any other idea to solve this matter?

tnx 4 any help!
regards, curtis
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> schrieb im
Newsbeitrag news:uV******** ******@tk2msftn gp13.phx.gbl...
OK, since you asked for it, I'll make it short:

Changing the serialization format of the DataSet:

Dim objDataSet As New System.Data.Dat aSet( "MyDataSetN ame" )
...
objCmd.Fill(obj DataSet, "MyTableNam e")
and the missing document declaration should not be a problem. Are you having a problem with a specific app?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"curtis m. west" <cu****@gr8.c h> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
hello NG

i try to create a little generic vb.net function for exporting

access-tables
to
xml-files.
---===>>> CUT IN <<<===---
Function fncXmlExport(By Val strDBpath As String, ByVal strTableName As
String, ByVal strXmlFileName As String)
Dim objDataSet As New System.Data.Dat aSet
Dim objXmlDocument As New System.Xml.XmlD ocument
Dim objCmd As System.Data.Ole Db.OleDbDataAda pter
Dim objCon As System.Data.Ole Db.OleDbConnect ion
Dim strCon As String
strCon = "provider=Micro soft.Jet.OLEDB. 4.0; data source=" & strDBpath
objCon = New System.Data.Ole Db.OleDbConnect ion(strCon)
objCmd = New System.Data.Ole Db.OleDbDataAda pter("select * from " &
strTableName, objCon)
objCmd.Fill(obj DataSet)
objCon.Close()
objXmlDocument. LoadXml(objData Set.GetXml())
objXmlDocument. Save(strXmlFile Name)
End Function
---===>>> CUT OUT <<<====---

so far, so good, the file is being created, but i am missing this line
--->>> CUT IN <<<---
<?xml version="1.0" encoding="UTF-8"?>
--->>> CUT OUT <<<---
at the beginning of the file - and therefore it is not recognized as a

valid
xml-file by other applications.
also a little problem, the file starts like this:
--->>> CUT IN <<<---
<NewDataSet>
<Table>
<IDAbschluss>39 5</IDAbschluss>
<strAnrede>Herr </strAnrede>
--->>> CUT OUT <<<---

how can i change "<NewDataSe t>" and "<Table>"?
tnx for a short feedback!
greetz, curtis


Nov 12 '05 #3
Off the top of my head ...

how about first generating an XML Schema that has the correct datatype
definitions. You could start with the schema that you have written out
already. Then change the type of the fields in the schema that are not
interpreted correctly to xs:string (or xsd:string, depending on the prefix
you have defined for http://www.w3.org/2001/XMLSchema) and the generate a
typed dataset. Another approach to this is add a typed dataset to your VS
project, then drag the table that you read from the server explorer to the
typed dataset design surface then hand edit it in the XML view.

Once you read your phone numbers as strings everything should be fine.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"curtis m. west" <cu****@gr8.c h> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
tnx for your anwer - helped very much!
i'm starting working my way into the DS-class (as i only used
ADODB-recordsets yet)...
so my path got to:
--->>> CUT IN <<<---
objDataSet.Writ eXml("d:\test.x ml", XmlWriteMode.Wr iteSchema)
or
objDataSet.Writ eXmlSchema("d:\ test.xsd")
objDataSet.Writ eXml("d:\test.x ml", XmlWriteMode.Ig noreSchema)
--->>> CUT OUT <<<---
what seems to be the better way for my needs. (also includes the document
declaration)

but still the some problems: there are phone-numbers in the table with
leading zeros (079######)
-if i use ".ignoreschema" , i miss the leasing zeros, as the field will be
recognized as a number-field.
-if i use ".writesche ma", it works fine while importing into ms-access...
but ms-excel does not recognize the inline-schema...
-if i use ".ignoresch ema" and write a separate-schema-file (.writexmlschem a) excel does not "link the two files together"
(is there a way to include a path to the schemafile in the datafile?)

any other idea to solve this matter?

tnx 4 any help!
regards, curtis
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> schrieb im Newsbeitrag news:uV******** ******@tk2msftn gp13.phx.gbl...
OK, since you asked for it, I'll make it short:

Changing the serialization format of the DataSet:

Dim objDataSet As New System.Data.Dat aSet( "MyDataSetN ame" )
...
objCmd.Fill(obj DataSet, "MyTableNam e")
and the missing document declaration should not be a problem. Are you

having
a problem with a specific app?

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"curtis m. west" <cu****@gr8.c h> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
hello NG

i try to create a little generic vb.net function for exporting

access-tables
to
xml-files.
---===>>> CUT IN <<<===---
Function fncXmlExport(By Val strDBpath As String, ByVal strTableName As
String, ByVal strXmlFileName As String)
Dim objDataSet As New System.Data.Dat aSet
Dim objXmlDocument As New System.Xml.XmlD ocument
Dim objCmd As System.Data.Ole Db.OleDbDataAda pter
Dim objCon As System.Data.Ole Db.OleDbConnect ion
Dim strCon As String
strCon = "provider=Micro soft.Jet.OLEDB. 4.0; data source=" & strDBpath objCon = New System.Data.Ole Db.OleDbConnect ion(strCon)
objCmd = New System.Data.Ole Db.OleDbDataAda pter("select * from " &
strTableName, objCon)
objCmd.Fill(obj DataSet)
objCon.Close()
objXmlDocument. LoadXml(objData Set.GetXml())
objXmlDocument. Save(strXmlFile Name)
End Function
---===>>> CUT OUT <<<====---

so far, so good, the file is being created, but i am missing this line
--->>> CUT IN <<<---
<?xml version="1.0" encoding="UTF-8"?>
--->>> CUT OUT <<<---
at the beginning of the file - and therefore it is not recognized as a

valid
xml-file by other applications.
also a little problem, the file starts like this:
--->>> CUT IN <<<---
<NewDataSet>
<Table>
<IDAbschluss>39 5</IDAbschluss>
<strAnrede>Herr </strAnrede>
--->>> CUT OUT <<<---

how can i change "<NewDataSe t>" and "<Table>"?
tnx for a short feedback!
greetz, curtis



Nov 12 '05 #4

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

Similar topics

0
2259
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, ${$val . 'XML'}, ${$val . 'XMLArray'}, $tags); xml_parser_free($parser); $myXMLArray = ${$val . 'XMLArray'}; for ($i = 1; $i < @sizeof($myXMLArray) - 1; $i++) { if ($myXMLArray) {
0
1755
by: Stylus Studio | last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks XML Schema Quality Checker to Improve XML Schema Style and Quality BEDFORD, MA -- 09/13/2005 -- Stylus Studio (http://www.stylusstudio.com), the industry-leading provider of XML development tools for advanced data integration, today announced new support for IBM's alphaWorks XML Schema Quality Checker, furthering solidifying its position as the provider of the...
5
2724
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use the appointment collection to populate the calendar control. The performance getting the XML data is fine, but loading the data into the collection is slow. My question/problem is should I be using the collection, a dataset, or something else to...
5
4205
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple values in the where clause as below
0
2789
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <product sku="10050-1653" xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <sku>10050-1653</sku> <name xml:lang="x-default">shop's Foie Gras</name> <online>1</online> ...
0
2234
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
9
2478
by: Lie | last post by:
Why this generates AttributeError, then not? Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'dom' <module 'xml.dom' from '/usr/lib/python2.5/xml/dom/__init__.pyc'>
10
15571
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must have a top level element. line #: 0 I don't know if it is my xml file or it is something else? Here is my client side program: <%@ Language=vbScript%>
0
2168
by: Jacker | last post by:
Xpress Author for MS Word XML Documents In.vision Research empowers knowledge workers to create complex XML documents in Microsoft Word (2000-2003) with a normal Word experience. Deploy XML authoring across the enterprise. http://e.goozw.com/xml.htm Powerful XML Editing Tool - XMLSPY XMLSPY is a powerful XML tool for editing XML documents, XML schema, DTDs, XSL/XSLT stylesheets, SOAP applications, debugging Web services and more....
0
8689
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8618
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9035
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6534
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3058
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
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.