How do I access certain values of an XML document?

Here’s my document:

<?xml version=”1.0″ encoding=”UTF-8″?>


<temperature value=”71.37″ min=”69.44″ max=”73.94″ unit=”fahrenheit”>



I just want to get the min and max temperatures but I don’t know how to access them. Here’s my code:

WebClient client = new WebClient();

// Get the response string from the URL.

string xml = client.DownloadString(url);

XmlDocument doc = new XmlDocument();


var items = doc.GetElementsByTagName(“temperature”);

foreach (var item in items)





The issue is that it just returns an empty line like it isn’t properly reading anything and I don’t know how to actually access the values I need. I’m very new to using XML documents so this is completely foreign to me. Any help is appreciated. Thanks!

submitted by /u/shoshy566
[link] [comments]

Leave a Reply