Skip to main content
added 268 characters in body
Source Link
TddOrBust
  • 414
  • 3
  • 12

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can eitherwill probably need to use whatever language you're doing this in (I'd bet it has a round down function). As @JLRishe observed and explained, your root appears to be a .NET XmlNode or XPathNavigator, which can only select the node, so the below won't work and will throw an exception. I've left this in to show that there are xpath floor function:functions for rounding.

string xmlNode = root.SelectSingleNode("floor(/observations/observation[@date='1976-01-01']/@value)").Value; 

If using the xpath function route (which it appears you can't use), and if you want to always round to the nearest integer, change floor to round. And if you want to always round up, change floor to ceiling.

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language you're doing this in (I'd bet it has a round down function) or the xpath floor function:

string xmlNode = root.SelectSingleNode("floor(/observations/observation[@date='1976-01-01']/@value)").Value; 

If using the xpath function route, and if you want to always round to the nearest integer, change floor to round. And if you want to always round up, change floor to ceiling.

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you will probably need to use whatever language you're doing this in (I'd bet it has a round down function). As @JLRishe observed and explained, your root appears to be a .NET XmlNode or XPathNavigator, which can only select the node, so the below won't work and will throw an exception. I've left this in to show that there are xpath functions for rounding.

string xmlNode = root.SelectSingleNode("floor(/observations/observation[@date='1976-01-01']/@value)").Value; 

If using the xpath function route (which it appears you can't use), and if you want to always round to the nearest integer, change floor to round. And if you want to always round up, change floor to ceiling.

added 2 characters in body
Source Link
TddOrBust
  • 414
  • 3
  • 12

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language you're doing this in (I'd bet it has a round down function) or the xpath roundfloor function:

string xmlNode = root.SelectSingleNode("round"floor(/observations/observation[@date='1976-01-01']/@value)").Value; 

If using the xpath function route, and if you want to always round to the nearest integer, change floor to round. And if you want to always round up, change floor to ceiling.

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language you're doing this in (I'd bet it has a round function) or the xpath round function:

string xmlNode = root.SelectSingleNode("round(/observations/observation[@date='1976-01-01']/@value)").Value; 

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language you're doing this in (I'd bet it has a round down function) or the xpath floor function:

string xmlNode = root.SelectSingleNode("floor(/observations/observation[@date='1976-01-01']/@value)").Value; 

If using the xpath function route, and if you want to always round to the nearest integer, change floor to round. And if you want to always round up, change floor to ceiling.

added 2 characters in body
Source Link
TddOrBust
  • 414
  • 3
  • 12

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language youryou're doing this in (I'd bet it has a round function) or the xpath round function:

string xmlNode = root.SelectSingleNode("round(/observations/observation[@date='1976-01-01']/@value)").Value; 

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language your doing this in (I'd bet it has a round function) or the xpath round function:

string xmlNode = root.SelectSingleNode("round(/observations/observation[@date='1976-01-01']/@value)").Value; 

This will do it:

string xmlNode = root.SelectSingleNode("/observations/observation[@date='1976-01-01']/@value").Value; 

What this says is to select the @value of the observation node whose date is 1976-01-01. And to get just the integer of @value, you can either use whatever language you're doing this in (I'd bet it has a round function) or the xpath round function:

string xmlNode = root.SelectSingleNode("round(/observations/observation[@date='1976-01-01']/@value)").Value; 
Source Link
TddOrBust
  • 414
  • 3
  • 12
Loading