-
Read From XML
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:
-
Easiest is to read your xml file into a dataset.
Code:
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
-
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.
-
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