Click to See Complete Forum and Search --> : Read From XML


Kate_For_U
May 2nd, 2003, 12:32 AM
Hi All

I want to read a particular data from an XML
e.g in the XML given below From node Services
I want to read value for Path or Frequency.

<Services>
<Path>E:\Attach2\ISE\TCG\</Path>
<Frequency>120</Frequency>
<LogFilePath>G:\TLOG\ISE\Test.txt</LogFilePath>
<FileExtn>.xls</FileExtn>
<Application>Mock2</Application>
</Services>

How to achieve this in VB.Net?

:confused:

DdH
May 2nd, 2003, 03:39 AM
Easiest is to read your xml file into a dataset.


Dim path As String
Dim ds As New System.Data.DataSet

ds.ReadXml("your xml file.xml")

path = ds.Tables("Services").Rows(0).Item("Path").ToString

Danny

Kate_For_U
May 2nd, 2003, 04:23 AM
The use of dataset can be done , but then this would add one more object.

Isn't there an inbuilt feature of .Net to do this.

coolbiz
May 5th, 2003, 10:23 PM
Look at SYSTEM.XML namespace. The steps should be:
1. Use XMLDOCUMENT object to read that XML string/file
2. Use SelectSingleNode() method of XMLDOCUMENT object to get the node (PATH or FREQUENCY) that you want.
3. Use Text property (i think that is the property that holds TEXT value for XMLNODE) to get the value of that node.

-Cool Bizs