easily reading and using an XML-string

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

DraguVaso

Hi,

I have an application that gets on a suden momenth a XML-string as parameter
(so NOT an XML-file or something like that!!). See it a little bit like a
user would type an XML-string in a Textbox.

This XML-string will be look like this: "<?xml
version="1.0"?><par><do>12345678901234</do><ca>1234567890123456</ca><c1>Mr.
Billing Billy</c1><c2>Miss. Janette
Jackson</c2><sc>TREC</sc><ch>Augmentation</ch></par>"

More structured it will be like this:
<?xml version="1.0"?>
<par>
<do>12345678901234</do>
<ca>1234567890123456</ca>
<c1>Mr. Billing Billy</c1>
<c2>Miss. Janette Jackson</c2>
<sc>TREC</sc>
<ch>Augmentation</ch>
</par>


So in my application I will have a string (strXML) which contains the whole
XML-string.

I want to be able to convert it to something, so I will be able to easily
check all the paramters in it. Something as easy accessibnle as a Collection
or a DataView or I don't know what. So I can do actions like: "strDossier =
colPar("do")" or "strDossier = dtvPar("do")" etc etc.

Does anybody knows how to do this? Is there a standard function for this? Or
should I need to write my own methods that read the string and put it into a
structure?

Thanks a lot in advance!

Pieter
 
Thanks!! That works great!!

Pieter

Jim Perry said:
Check out the XMLDocument class and the LoadXML method for loading the string:

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample

Public Shared Sub Main()
'Create the XmlDocument.
Dim doc As New XmlDocument()
doc.LoadXml(("<book genre='novel' ISBN='1-861001-57-5'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>"))

'Save the document to a file.
doc.Save("data.xml")
End Sub 'Main
End Class 'Sample

You can then use the class's method for searching for specific nodes and
the info they contain.
 
Back
Top