newbie: Loading XML and storing values of attributes in a String

  • Thread starter Thread starter abdul bari
  • Start date Start date
A

abdul bari

Hi

How do I load the following XML and store the values of the attributes
of the childnodes in String variables.

<?xml version="1.0" standalone="yes" ?>
- <DeviceProfile>
Profile of Device
<DeviceName>Kettle</DeviceName>
<DeviceIP>127.0.0.1</DeviceIP>
<InterfaceID>Light01</InterfaceID>
<DeviceStatus>OFF</DeviceStatus>
<DeviceDescription>Bedroom</DeviceDescription>
</DeviceProfile>

Thanks your help would be much appreciated.
Abz
 
DataSet ds = new DataSet();

ds.ReadXml("fileName.xml");

string deviceName =
ds.Tables["DeviceProfile"].Rows[0]["DeviceName"].ToString();

HTH
 
Back
Top