473,385 Members | 1,912 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,385 software developers and data experts.

XML Visual Basic Questions

First let me say I am familar with programming, but not familiar with VB.net.

I am loading an existing XML document with this procedure

Dim xmlFile As String = "..\data\Products.xml"
Dim xmlDoc As XmlDocument

Private Sub Zadig_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim xmlTr As New XmlTextReader(xmlFile)

While xmlTr.Read
If xmlTr.Name = "id" AndAlso xmlTr.NodeType =
XmlNodeType.Element Then
cmbProducts.Items.Add(xmlTr.ReadString)
End If
End While
xmlTr.Close()

xmlDoc = New XmlDocument
xmlDoc.Load(xmlFile)

End Sub

If I have a NEW form (IE-Products.vb), will I be able to reference the XML
doc in Memory?

Also, is there a good web reference that shows how to update
XML data (In memory) and then write them back out to a file?

Thanks,

Michael

Jul 21 '05 #1
11 1589
Fremenusul.

When you start with VBNet or beter dotNet and will use XML, you have
yourself first is this an data file or a document.

When it is a data file you would first have a look at the dataset, because
that has its own methods to handle elements, which are a lot easier than the
loaddoc and the xmlreader.

When you have more questions, please reply

Cor
Jul 21 '05 #2
Each instance of form Zadig will have it's own copy of the xmlDoc variable,
but other form types will not. To share the xmlDoc variable amoungst forms
will require that you make it Public. A good way of exposing it would be the
Singleton Pattern:

Public Class Settings

Private Shared xmlDoc As XmlDocument

Public Shared Property Products As XmlDocument
Get
If xmlDoc Is Nothing Then
' Initialize & load xmlDoc here
End If

Return xmlDoc
End Get
End Property

End Class

Then to access the XmlDocument you'd just do:
Settings.Products

Have a look at
http://samples.gotdotnet.com/quickst...viewofxml.aspx for
more information on using XML in an application.

"fremenusul" <fr********@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
First let me say I am familar with programming, but not familiar with
VB.net.

I am loading an existing XML document with this procedure

Dim xmlFile As String = "..\data\Products.xml"
Dim xmlDoc As XmlDocument

Private Sub Zadig_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim xmlTr As New XmlTextReader(xmlFile)

While xmlTr.Read
If xmlTr.Name = "id" AndAlso xmlTr.NodeType =
XmlNodeType.Element Then
cmbProducts.Items.Add(xmlTr.ReadString)
End If
End While
xmlTr.Close()

xmlDoc = New XmlDocument
xmlDoc.Load(xmlFile)

End Sub

If I have a NEW form (IE-Products.vb), will I be able to reference the XML
doc in Memory?

Also, is there a good web reference that shows how to update
XML data (In memory) and then write them back out to a file?

Thanks,

Michael

Jul 21 '05 #3
Why is datafile better? I am learning and want to understand the "why's" as
much as the "how's".

Thanks,

Michael

"Cor Ligthert" wrote:
Fremenusul.

When you start with VBNet or beter dotNet and will use XML, you have
yourself first is this an data file or a document.

When it is a data file you would first have a look at the dataset, because
that has its own methods to handle elements, which are a lot easier than the
loaddoc and the xmlreader.

When you have more questions, please reply

Cor

Jul 21 '05 #4
It's just about the programming model. Instead of seing your document as an
XML file you'll see it at a collection of rows with columns as if it were
coming from a DB...

Patrice

--

"fremenusul" <fr********@discussions.microsoft.com> a écrit dans le message
de news:70**********************************@microsof t.com...
Why is datafile better? I am learning and want to understand the "why's" as much as the "how's".

Thanks,

Michael

"Cor Ligthert" wrote:
Fremenusul.

When you start with VBNet or beter dotNet and will use XML, you have
yourself first is this an data file or a document.

When it is a data file you would first have a look at the dataset, because that has its own methods to handle elements, which are a lot easier than the loaddoc and the xmlreader.

When you have more questions, please reply

Cor

Jul 21 '05 #5
Fremesul,

I checked it because I was surprised that I wrote "better". There is in my
opinion no "best" solution, every solution has a better alternative and I
don't know if that is in this case. I wrote "easier".

However, the dataset is made to cooperate with SQL based databaseservers and
has therefore every functionality to handle it.

Basically it exist from collections of datatables, which have collections
of datarows, which have collections of dataitems. The dataitems are
described in datacolumns. While as well it is possible to make relations in
this for the tables.

It has a lot of standard methods in dotnet to send and use in different
ways.

To give you four samples in VBNet format,

reading of a dataset from a disk is.
mydataset.readXML("path").
writing
mydataset.writeXML("path")
showing the complete dataset in a datagrid
mydatagrid1.datasource = mydataset
getting the first item from the first row from the first table
mydataset.tables(0).rows(0)(0)
or when it would have had names
mydataset.tables("myfirsttable").rows(0).items("My FirstItem")

However, this is just the begin and all based on data.

I hope this gives some ideas'

Cor

"fremenusul" <fr********@discussions.microsoft.com> schreef in bericht
news:70**********************************@microsof t.com...
Why is datafile better? I am learning and want to understand the "why's"
as
much as the "how's".

Thanks,

Michael

"Cor Ligthert" wrote:
Fremenusul.

When you start with VBNet or beter dotNet and will use XML, you have
yourself first is this an data file or a document.

When it is a data file you would first have a look at the dataset,
because
that has its own methods to handle elements, which are a lot easier than
the
loaddoc and the xmlreader.

When you have more questions, please reply

Cor

Jul 21 '05 #6
Patrice,
It's just about the programming model. Instead of seing your document as
an
XML file you'll see it at a collection of rows with columns as if it were
coming from a DB...


In my opinion wrong; every dataset can be a XML file, not every XML file is
a dataset.

Cor
Jul 21 '05 #7
Is this what I said ?

Was just trying to respond to fremensul that wanted to know why you
suggested to use a DataSet for XML data files. My remakrs about the
programming model is to be taken in this context, not that you should always
handle all XML files on earth using this programming model...

Patrice
--

"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:%2****************@TK2MSFTNGP12.phx.gbl...
Patrice,
It's just about the programming model. Instead of seing your document as
an
XML file you'll see it at a collection of rows with columns as if it were coming from a DB...
In my opinion wrong; every dataset can be a XML file, not every XML file

is a dataset.

Cor

Jul 21 '05 #8
Patrice,

Je pense que c'était mon mauvaise idée au sujet de votre texte.
I think that it was my wrong idea about your text.

Excusez-moi.
Sorry

:-)

Cor
Jul 21 '05 #9
Sorry, it sometimes a bit hard to express yourself or to understand what
others are saying. I even wondered before answering as this is not so
important fbut found a bit strange your response in this context.

Later in this group - you saw English is not my native language ;-)

Patrice

--

"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:%2****************@TK2MSFTNGP09.phx.gbl...
Patrice,

Je pense que c'était mon mauvaise idée au sujet de votre texte.
I think that it was my wrong idea about your text.

Excusez-moi.
Sorry

:-)

Cor

Jul 21 '05 #10
Thanks to everyone that replied. I will be reading over all the answers and
most likley, asking lots more questions.

Thanks again.

"Cor Ligthert" wrote:
Fremesul,

I checked it because I was surprised that I wrote "better". There is in my
opinion no "best" solution, every solution has a better alternative and I
don't know if that is in this case. I wrote "easier".

However, the dataset is made to cooperate with SQL based databaseservers and
has therefore every functionality to handle it.

Basically it exist from collections of datatables, which have collections
of datarows, which have collections of dataitems. The dataitems are
described in datacolumns. While as well it is possible to make relations in
this for the tables.

It has a lot of standard methods in dotnet to send and use in different
ways.

To give you four samples in VBNet format,

reading of a dataset from a disk is.
mydataset.readXML("path").
writing
mydataset.writeXML("path")
showing the complete dataset in a datagrid
mydatagrid1.datasource = mydataset
getting the first item from the first row from the first table
mydataset.tables(0).rows(0)(0)
or when it would have had names
mydataset.tables("myfirsttable").rows(0).items("My FirstItem")

However, this is just the begin and all based on data.

I hope this gives some ideas'

Cor

"fremenusul" <fr********@discussions.microsoft.com> schreef in bericht
news:70**********************************@microsof t.com...
Why is datafile better? I am learning and want to understand the "why's"
as
much as the "how's".

Thanks,

Michael

"Cor Ligthert" wrote:
Fremenusul.

When you start with VBNet or beter dotNet and will use XML, you have
yourself first is this an data file or a document.

When it is a data file you would first have a look at the dataset,
because
that has its own methods to handle elements, which are a lot easier than
the
loaddoc and the xmlreader.

When you have more questions, please reply

Cor


Jul 21 '05 #11
A followup question...

If I use XmlDocument (DOM implimentation I believe) I can "append" data to
my XML file right (In memory). Then when I am done, I can "output" a xml file.

Is there somewhere that can explain this process clearly? Read in XML file,
modify the xml (in memory) then output it back out???

Thanks for any help.

"Sean Hederman" wrote:
Each instance of form Zadig will have it's own copy of the xmlDoc variable,
but other form types will not. To share the xmlDoc variable amoungst forms
will require that you make it Public. A good way of exposing it would be the
Singleton Pattern:

Public Class Settings

Private Shared xmlDoc As XmlDocument

Public Shared Property Products As XmlDocument
Get
If xmlDoc Is Nothing Then
' Initialize & load xmlDoc here
End If

Return xmlDoc
End Get
End Property

End Class

Then to access the XmlDocument you'd just do:
Settings.Products

Have a look at
http://samples.gotdotnet.com/quickst...viewofxml.aspx for
more information on using XML in an application.

"fremenusul" <fr********@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
First let me say I am familar with programming, but not familiar with
VB.net.

I am loading an existing XML document with this procedure

Dim xmlFile As String = "..\data\Products.xml"
Dim xmlDoc As XmlDocument

Private Sub Zadig_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim xmlTr As New XmlTextReader(xmlFile)

While xmlTr.Read
If xmlTr.Name = "id" AndAlso xmlTr.NodeType =
XmlNodeType.Element Then
cmbProducts.Items.Add(xmlTr.ReadString)
End If
End While
xmlTr.Close()

xmlDoc = New XmlDocument
xmlDoc.Load(xmlFile)

End Sub

If I have a NEW form (IE-Products.vb), will I be able to reference the XML
doc in Memory?

Also, is there a good web reference that shows how to update
XML data (In memory) and then write them back out to a file?

Thanks,

Michael


Jul 21 '05 #12

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

Similar topics

1
by: angelag | last post by:
I am currently taking a college course in Visual Basic.Net and I am a beginner. I bought Visual Studio.Net 2003 to do my homework at home. I built my first project and e-mailed it to myself at...
2
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
1
by: Al Murphy | last post by:
Hi, I hope that you can help me wit this one please and apologies if i'm in the wrong forum! I recently bought a book that contaiend a CD-ROM of very useful Visual Basic algoritms. Now these...
8
by: Orange Free | last post by:
I want to create a program that will ask a user a series of questions and then generate a Microsoft Word document whose content is dictated by the answers. I am not a professional programmer, and...
5
by: john | last post by:
I searched http://www.sellsbrothers.com. and could not find anything about this subject. How do I make C# User Controls Visible to Visual Basic 6.0 Applications? Thanks, John
0
by: software2006 | last post by:
ASP And Visual Basic Interview questions and answers I have listed over 100 ASP and Visual Basic interview questions and answers in my website...
1
by: czi02 | last post by:
Im just try to go in the html ask a questions because in the visual basic ask a quetion they do not know on how how to connect html to visual basic?? What components am i going to used and what is...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
8
by: Chris Asaipillai | last post by:
Hi there I have some questions for those experienced Visual Basic 6 programmers out there who have made the transition from VB6 to Vb.net. How long did it take you to learn at least the basic...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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,...
0
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...

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.