I have an XML file structured like this:
<?xml version="1.0" encoding="utf-8"?> <PresCrt> <Times> <Time hours="0">2015-06-20T00:00:00Z</Time> <Time hours="12">2015-06-20T12:00:00Z</Time> <Time hours="24">2015-06-21T00:00:00Z</Time> <Time hours="36">2015-06-21T12:00:00Z</Time> <Time hours="48">2015-06-22T00:00:00Z</Time> <Time hours="60">2015-06-22T12:00:00Z</Time> <Time hours="72">2015-06-23T00:00:00Z</Time> <Time hours="84">2015-06-23T12:00:00Z</Time> </Times> </PresCrt>
It contains Time nodes with values/InnerText of times that pressure forecast charts are valid from. Each Time node also contains an attribute with a value for the number of hours into the future the Time node value is for.
In my program I download new data and extract the times and hour number values from it and save them in the format above. I also make a List(string) of the new values. Then I loop through the times in the newly downloaded data using XPath and use List.Contains on the List(string) to see if they are already in the List(string). Any that are not already in the list get added to a new List(string) so that their charts can be downloaded later.
This is where my problem occurs: I loop through the new list of times to download them, however the URL requires the hour value which isn't stored in the looped list but is stored in the xml file as the attribute. I need to get the hour value which is an attribute, using the value of the node (the times I am looping in the list). I have gone through many searches to try to find an answer but all I get is how to find the value of a node with a specific attribute value (which I know how to do anyway, using node[@attribute='value']/node). How can I do the opposite and find the value of an attribute from the value of its node? Thanks for any help