putting parameters into XML and than in collection?

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

Hi,

I have application A giving 1 string containing some parameter to
application B. I guess it would be 'nice' if I made that parameter-string in
XML-format.

In my application B I need a way to find out easily which parameters are put
into the XML-string, and I need to be able to work easily with them. Would
it be good to read out the XML and put it in a Collection? Or a better way
how to do that? Is it really necessary to transform it into sometyhing else
in the application?


Other question: I'm not really familiar with XML. Is there somewhere a quick
overview on how I need to use it to perform such an operations? Like a
little explanation that takes me 30'? :-)


Thanks a lot in advance,

Pieter
 
Hallo Pieter,

There is XML and XML.

For the javascript programmer it is a document. For the VB.net programmer a
Dataset.

Internaly they are totally different in my opinion.

For most purposes in VB.net we can use the dataset, that gives us easy
handling.

You can start with making it by opening a dataset (XSD) in the designer
(solution explorer) and than just add the elements you want.

That you can read as a dataset just with

dataset11.readxml(path) and write it with dataset11.writexml(path)

The usage of a xmldocument is totally different from this.

I hope this helps something if not ask further?

Cor
 
Hi Cor,

This isn't exactly what I was looking for.
In my 'receiving' application I will receive a string (not a file!),
something like this I guess:

<?xml version="1.0"
standalone="yes"?><Parameters><Param1>blabla</Param1><Param2>another
parameter</Param><Param1>something else</Param1></Parameters>

I guess this is XML, hehe :-) Or I want it to be formatted as XML.

But than in my 'receiving' application I need to take it apart as a
collection or something like this, or maybe a dataset, which is fine for me.
How do I do this?


And is there anywhere a fine site which explains a little bit how to do
this?

Thanks, Pieter
 
Hallo Pieter,

Does this what you want?

Cor
\\\
Dim ds As New DataSet
Dim dt As New DataTable("parameters")
For c As Integer = 1 To 10
Dim dc As New DataColumn("elem" & c.tostring)
dt.Columns.Add(dc)
Next
For r As Integer = 1 To 10
Dim dr As DataRow = dt.NewRow
For c As Integer = 1 To 10
dr("elem" & c.tostring) = _
r.ToString & c.tostring ' or just dr(c) but to show you
Next
dt.Rows.Add(dr) ' can also before but I find this looking nicer
Next
ds.Tables.Add(dt)
Dim ser As XmlSerializer = New XmlSerializer(GetType(DataSet))
Dim ms As New IO.MemoryStream
Dim sw As IO.TextWriter = New IO.StreamWriter(ms)
ser.Serialize(sw, ds)
Dim b As Long = ms.Length
ms.Position = 0
Dim sr As IO.TextReader = New IO.StreamReader(ms)
Dim xmlstring As String = sr.ReadToEnd
sw.Close()
sr.Close()
ms.Close()
///
 
I didn't test it yet, but I guess I'll be able to do with this what I need,
or at least it show me the possibilities and the use of it.

Thanks a lot and have a nice new week, hehe :-)
 
Back
Top