Larry,
i've got an xml file which has multiple cities as the top level item.
When i read it in using XMLReader, and define the variables, as below, it
finds the correct number of cities in the xml file, but repeats the first
one 3 times. I'm sure its something minor but i just cant seem to figure it
out.
here is the XML, and source code below:
--------------------XML---------------------
<?xml version="1.0" encoding="utf-8"?>
<weatherFeed>
<city>
<currentConditions>
country>Austria</country>
<city>Vienna</city>
<weatherImageURL>weather/lrg/sunny.gif</weatherImageURL>
<celcius>1°C</celcius>
<farenheit>34°F</farenheit>
<description>Sunny</description>
<relativeHumidity>69%</relativeHumidity>
<wind>N at 1 mph (2 km/h)</wind>
<sunrise>7:37 AM</sunrise>
<sunset>4:32 PM</sunset>
<barometricPressure>30.1Hg (F)</barometricPressure>
<lastUpdated>1/19/2004 4:01:12 AM</lastUpdated>
</currentConditions>
<!--5 Day Weather Forecast-->
<fiveDayForecast>
<Day1>
<day>Monday</day>
<highCelcius>1°C</highCelcius>
<lowCelcius>-4°C</lowCelcius>
<highFarenheit>33°F</highFarenheit>
<lowFarenheit>24°F</lowFarenheit>
<imageURL>weather/med/partly.cloudy.gif</imageURL>
</Day1>
<Day2>
<day>Tuesday</day>
<highCelcius>1°C</highCelcius>
<lowCelcius>-6°C</lowCelcius>
<highFarenheit>34°F</highFarenheit>
<lowFarenheit>21°F</lowFarenheit>
<imageURL>weather/med/snow.gif</imageURL>
</Day2>
<Day3>
<day>Wednesday</day>
<highCelcius>-4°C</highCelcius>
<lowCelcius>-8°C</lowCelcius>
<highFarenheit>25°F</highFarenheit>
<lowFarenheit>17°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day3>
<Day4>
<day>Thursday</day>
<highCelcius>-2°C</highCelcius>
<lowCelcius>-2°C</lowCelcius>
<highFarenheit>29°F</highFarenheit>
<lowFarenheit>28°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day4>
<Day5>
<day>Friday</day>
<highCelcius>-2°C</highCelcius>
<lowCelcius>1°C</lowCelcius>
<highFarenheit>29°F</highFarenheit>
<lowFarenheit>33°F</lowFarenheit>
<imageURL>weather/med/partly.cloudy.gif</imageURL>
</Day5>
</fiveDayForecast>
</city>
<city>
<currentConditions>
<country>Austria</country>
<city>Innsbruck</city>
<weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL>
<celcius>0°C</celcius>
<farenheit>32°F</farenheit>
<description>Mostly Cloudy</description>
<relativeHumidity>74%</relativeHumidity>
<wind>N at 1 mph (2 km/h)</wind>
<sunrise>7:55 AM</sunrise>
<sunset>4:56 PM</sunset>
<barometricPressure>30.13Hg (F)</barometricPressure>
<lastUpdated>1/19/2004 4:01:12 AM</lastUpdated>
</currentConditions>
<!--5 Day Weather Forecast-->
<fiveDayForecast>
<Day1>
<day>Monday</day>
<highCelcius>-2°C</highCelcius>
<lowCelcius>-8°C</lowCelcius>
<highFarenheit>29°F</highFarenheit>
<lowFarenheit>17°F</lowFarenheit>
<imageURL>weather/med/partly.cloudy.gif</imageURL>
</Day1>
<Day2>
<day>Tuesday</day>
<highCelcius>0°C</highCelcius>
<lowCelcius>-12°C</lowCelcius>
<highFarenheit>32°F</highFarenheit>
<lowFarenheit>10°F</lowFarenheit>
<imageURL>weather/med/snow.gif</imageURL>
</Day2>
<Day3>
<day>Wednesday</day>
<highCelcius>-6°C</highCelcius>
<lowCelcius>-15°C</lowCelcius>
<highFarenheit>22°F</highFarenheit>
<lowFarenheit>5°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day3>
<Day4>
<day>Thursday</day>
<highCelcius>1°C</highCelcius>
<lowCelcius>-3°C</lowCelcius>
<highFarenheit>34°F</highFarenheit>
<lowFarenheit>26°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day4>
<Day5>
<day>Friday</day>
<highCelcius>1°C</highCelcius>
<lowCelcius>-3°C</lowCelcius>
<highFarenheit>34°F</highFarenheit>
<lowFarenheit>27°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day5>
</fiveDayForecast>
</city>
<city>
<currentConditions>
<!--URL: http://weather.cnn.com/weather/forecast.jsp?locCode=LOWS-->
<country>Austria</country>
<city>Salzburg</city>
<weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL>
<celcius>0°C</celcius>
<farenheit>32°F</farenheit>
<description>Mostly Cloudy</description>
<relativeHumidity>86%</relativeHumidity>
<wind>NNW at 2 mph (3 km/h)</wind>
<sunrise>7:50 AM</sunrise>
<sunset>4:48 PM</sunset>
<barometricPressure>30.1Hg (F)</barometricPressure>
<lastUpdated>1/19/2004 4:01:12 AM</lastUpdated>
</currentConditions>
<fiveDayForecast>
<Day1>
<day>Monday</day>
<highCelcius>0°C</highCelcius>
<lowCelcius>-5°C</lowCelcius>
<highFarenheit>32°F</highFarenheit>
<lowFarenheit>23°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day1>
<Day2>
<day>Tuesday</day>
<highCelcius>2°C</highCelcius>
<lowCelcius>-9°C</lowCelcius>
<highFarenheit>35°F</highFarenheit>
<lowFarenheit>15°F</lowFarenheit>
<imageURL>weather/med/snow.gif</imageURL>
</Day2>
<Day3>
<day>Wednesday</day>
<highCelcius>-4°C</highCelcius>
<lowCelcius>-12°C</lowCelcius>
<highFarenheit>24°F</highFarenheit>
<lowFarenheit>11°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day3>
<Day4>
<day>Thursday</day>
<highCelcius>3°C</highCelcius>
<lowCelcius>1°C</lowCelcius>
<highFarenheit>37°F</highFarenheit>
<lowFarenheit>33°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day4>
<Day5>
<day>Friday</day>
<highCelcius>3°C</highCelcius>
<lowCelcius>0°C</lowCelcius>
<highFarenheit>37°F</highFarenheit>
<lowFarenheit>32°F</lowFarenheit>
<imageURL>weather/med/cloudy.gif</imageURL>
</Day5>
</fiveDayForecast>
</city>
</weatherFeed>
----------------SOURCE CODE-----------------
Dim xDoc As New XmlDocument
Dim xe_weatherFeed As XmlElement
Dim xe_city As XmlNode
Dim xe_currentConditions As XmlElement
Dim xe_currentConditionsChild As XmlNode
Dim xe_fiveDayForecast As XmlElement
Dim xe_fiveDayForecastDay As XmlElement
Dim xe_fiveDayForecastDayDetails As XmlNode
Try
Dim a() As String
Dim al As New ArrayList
Dim i As Integer
xDoc.Load(strBaseURL & "weather/" &
Request.QueryString("countryID") & ".xml")
xe_weatherFeed = xDoc.SelectSingleNode("/weatherFeed")
xe_city = xDoc.SelectSingleNode("/weatherFeed/city")
xe_currentConditions =
xDoc.SelectSingleNode("/weatherFeed/city/currentConditions")
xe_fiveDayForecast =
xDoc.SelectSingleNode("/weatherFeed/city/fiveDayForecast")
For Each xe_city In xe_weatherFeed.ChildNodes
If xe_city.NodeType = XmlNodeType.Element Then
ReDim Preserve a(41)
i = 0
For Each xe_currentConditionsChild In
xe_currentConditions.ChildNodes
If xe_currentConditionsChild.NodeType =
XmlNodeType.Element Then
a(i) = xe_currentConditionsChild.InnerText
i += 1
End If
Next
For Each xe_fiveDayForecastDay In xe_fiveDayForecast
For Each xe_fiveDayForecastDayDetails In
xe_fiveDayForecastDay
If xe_fiveDayForecastDayDetails.NodeType =
XmlNodeType.Element Then
a(i) =
xe_fiveDayForecastDayDetails.InnerText
i += 1
End If
Next
Next
al.Add(a)
End If
Next
weatherRepeater.DataSource = al
weatherRepeater.DataBind()
Catch err As Exception
Response.Write("<br><font color=red><b>" & err.Message &
"</b></font>")
Finally
xDoc = Nothing
End Try
thanks in advance
Paul. 4 1652
Hi Paul,
I think I see why you getting the first city 3 times. It has to do with
your how you are using the xpath expression to assign the variable
xe_CurrentConditions. xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions")
Your xpath expression is always returns the 1st occurence of the
currentConditions element because your search is always occuring from the
top level xml element reference, xDoc.
Try moving the assignment of xe_CurrentConditions after your
For Each xe_city In xe_weatherFeed.ChildNodes
and change the statement to read:
xe_CurrentConditions = xe_City.SelectSingleNode("currentConditions")
That way your are getting the current conditions child relative to the
current iteration of xe_city
rather than always the first one.
If you are using Visual Studio and have the debugger available to you,
examine the values of the variables as you step through the program. It
will lend a lot of insight to what is happening.
LarryR
"Paul M" <mi******@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl... Larry,
i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below, it finds the correct number of cities in the xml file, but repeats the first one 3 times. I'm sure its something minor but i just cant seem to figure
it out.
here is the XML, and source code below:
--------------------XML--------------------- <?xml version="1.0" encoding="utf-8"?> <weatherFeed> <city> <currentConditions> country>Austria</country> <city>Vienna</city> <weatherImageURL>weather/lrg/sunny.gif</weatherImageURL> <celcius>1°C</celcius> <farenheit>34°F</farenheit> <description>Sunny</description> <relativeHumidity>69%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:37 AM</sunrise> <sunset>4:32 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-4°C</lowCelcius> <highFarenheit>33°F</highFarenheit> <lowFarenheit>24°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-6°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>21°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>25°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-2°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>28°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <country>Austria</country> <city>Innsbruck</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>74%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:55 AM</sunrise> <sunset>4:56 PM</sunset> <barometricPressure>30.13Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>10°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-6°C</highCelcius> <lowCelcius>-15°C</lowCelcius> <highFarenheit>22°F</highFarenheit> <lowFarenheit>5°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>26°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>27°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <!--URL: http://weather.cnn.com/weather/forecast.jsp?locCode=LOWS--> <country>Austria</country> <city>Salzburg</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>86%</relativeHumidity> <wind>NNW at 2 mph (3 km/h)</wind> <sunrise>7:50 AM</sunrise> <sunset>4:48 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-5°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>23°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>2°C</highCelcius> <lowCelcius>-9°C</lowCelcius> <highFarenheit>35°F</highFarenheit> <lowFarenheit>15°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>24°F</highFarenheit> <lowFarenheit>11°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>3°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>3°C</highCelcius> <lowCelcius>0°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>32°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> </weatherFeed>
----------------SOURCE CODE----------------- Dim xDoc As New XmlDocument Dim xe_weatherFeed As XmlElement Dim xe_city As XmlNode Dim xe_currentConditions As XmlElement Dim xe_currentConditionsChild As XmlNode Dim xe_fiveDayForecast As XmlElement Dim xe_fiveDayForecastDay As XmlElement Dim xe_fiveDayForecastDayDetails As XmlNode
Try Dim a() As String Dim al As New ArrayList Dim i As Integer
xDoc.Load(strBaseURL & "weather/" & Request.QueryString("countryID") & ".xml") xe_weatherFeed = xDoc.SelectSingleNode("/weatherFeed") xe_city = xDoc.SelectSingleNode("/weatherFeed/city") xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions") xe_fiveDayForecast = xDoc.SelectSingleNode("/weatherFeed/city/fiveDayForecast")
For Each xe_city In xe_weatherFeed.ChildNodes If xe_city.NodeType = XmlNodeType.Element Then ReDim Preserve a(41) i = 0 For Each xe_currentConditionsChild In xe_currentConditions.ChildNodes If xe_currentConditionsChild.NodeType = XmlNodeType.Element Then a(i) = xe_currentConditionsChild.InnerText i += 1 End If Next
For Each xe_fiveDayForecastDay In
xe_fiveDayForecast For Each xe_fiveDayForecastDayDetails In xe_fiveDayForecastDay If xe_fiveDayForecastDayDetails.NodeType = XmlNodeType.Element Then a(i) = xe_fiveDayForecastDayDetails.InnerText i += 1 End If Next Next al.Add(a) End If Next weatherRepeater.DataSource = al weatherRepeater.DataBind() Catch err As Exception Response.Write("<br><font color=red><b>" & err.Message & "</b></font>") Finally xDoc = Nothing End Try
thanks in advance
Paul.
Thanks larry,
i've got it on the debugger and can see it looping through the cities, and i
have experimented with moving the assigning of the variables inside the for
loop.
I'm sure i'm close and shall get it soon.
thanks again for your help and i'll reply with a result.
regards,
Paul.
"LarryR" <me@somewhere.com> wrote in message
news:r4SOb.7359$dd6.3614@lakeread02... Hi Paul,
I think I see why you getting the first city 3 times. It has to do with your how you are using the xpath expression to assign the variable xe_CurrentConditions.
xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions")
Your xpath expression is always returns the 1st occurence of the currentConditions element because your search is always occuring from the top level xml element reference, xDoc.
Try moving the assignment of xe_CurrentConditions after your
> For Each xe_city In xe_weatherFeed.ChildNodes
and change the statement to read:
xe_CurrentConditions = xe_City.SelectSingleNode("currentConditions")
That way your are getting the current conditions child relative to the current iteration of xe_city rather than always the first one.
If you are using Visual Studio and have the debugger available to you, examine the values of the variables as you step through the program. It will lend a lot of insight to what is happening.
LarryR
"Paul M" <mi******@hotmail.com> wrote in message news:uV**************@TK2MSFTNGP11.phx.gbl... Larry,
i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below,
it finds the correct number of cities in the xml file, but repeats the
first one 3 times. I'm sure its something minor but i just cant seem to figure it out.
here is the XML, and source code below:
--------------------XML--------------------- <?xml version="1.0" encoding="utf-8"?> <weatherFeed> <city> <currentConditions> country>Austria</country> <city>Vienna</city> <weatherImageURL>weather/lrg/sunny.gif</weatherImageURL> <celcius>1°C</celcius> <farenheit>34°F</farenheit> <description>Sunny</description> <relativeHumidity>69%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:37 AM</sunrise> <sunset>4:32 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-4°C</lowCelcius> <highFarenheit>33°F</highFarenheit> <lowFarenheit>24°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-6°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>21°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>25°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-2°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>28°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <country>Austria</country> <city>Innsbruck</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>74%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:55 AM</sunrise> <sunset>4:56 PM</sunset> <barometricPressure>30.13Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>10°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-6°C</highCelcius> <lowCelcius>-15°C</lowCelcius> <highFarenheit>22°F</highFarenheit> <lowFarenheit>5°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>26°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>27°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <!--URL:
http://weather.cnn.com/weather/forecast.jsp?locCode=LOWS--> <country>Austria</country> <city>Salzburg</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>86%</relativeHumidity> <wind>NNW at 2 mph (3 km/h)</wind> <sunrise>7:50 AM</sunrise> <sunset>4:48 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-5°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>23°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>2°C</highCelcius> <lowCelcius>-9°C</lowCelcius> <highFarenheit>35°F</highFarenheit> <lowFarenheit>15°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>24°F</highFarenheit> <lowFarenheit>11°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>3°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>3°C</highCelcius> <lowCelcius>0°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>32°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> </weatherFeed>
----------------SOURCE CODE----------------- Dim xDoc As New XmlDocument Dim xe_weatherFeed As XmlElement Dim xe_city As XmlNode Dim xe_currentConditions As XmlElement Dim xe_currentConditionsChild As XmlNode Dim xe_fiveDayForecast As XmlElement Dim xe_fiveDayForecastDay As XmlElement Dim xe_fiveDayForecastDayDetails As XmlNode
Try Dim a() As String Dim al As New ArrayList Dim i As Integer
xDoc.Load(strBaseURL & "weather/" & Request.QueryString("countryID") & ".xml") xe_weatherFeed = xDoc.SelectSingleNode("/weatherFeed") xe_city = xDoc.SelectSingleNode("/weatherFeed/city") xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions") xe_fiveDayForecast = xDoc.SelectSingleNode("/weatherFeed/city/fiveDayForecast")
For Each xe_city In xe_weatherFeed.ChildNodes If xe_city.NodeType = XmlNodeType.Element Then ReDim Preserve a(41) i = 0 For Each xe_currentConditionsChild In xe_currentConditions.ChildNodes If xe_currentConditionsChild.NodeType = XmlNodeType.Element Then a(i) =
xe_currentConditionsChild.InnerText i += 1 End If Next
For Each xe_fiveDayForecastDay In xe_fiveDayForecast For Each xe_fiveDayForecastDayDetails In xe_fiveDayForecastDay If xe_fiveDayForecastDayDetails.NodeType
= XmlNodeType.Element Then a(i) = xe_fiveDayForecastDayDetails.InnerText i += 1 End If Next Next al.Add(a) End If Next weatherRepeater.DataSource = al weatherRepeater.DataBind() Catch err As Exception Response.Write("<br><font color=red><b>" & err.Message & "</b></font>") Finally xDoc = Nothing End Try
thanks in advance
Paul.
Hi Larry,
thanks for that. As hard as i was staring at the code i didnt realise that
the SelectSingleNode method was always referencing xDoc instead of xe_city.
Everything is working exactly as i want now.
Many thanks again for your help and i appreciate the time you've taken to
help me out with your useful responses.
regards,
Paul.
"LarryR" <me@somewhere.com> wrote in message
news:r4SOb.7359$dd6.3614@lakeread02... Hi Paul,
I think I see why you getting the first city 3 times. It has to do with your how you are using the xpath expression to assign the variable xe_CurrentConditions.
xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions")
Your xpath expression is always returns the 1st occurence of the currentConditions element because your search is always occuring from the top level xml element reference, xDoc.
Try moving the assignment of xe_CurrentConditions after your
> For Each xe_city In xe_weatherFeed.ChildNodes
and change the statement to read:
xe_CurrentConditions = xe_City.SelectSingleNode("currentConditions")
That way your are getting the current conditions child relative to the current iteration of xe_city rather than always the first one.
If you are using Visual Studio and have the debugger available to you, examine the values of the variables as you step through the program. It will lend a lot of insight to what is happening.
LarryR
"Paul M" <mi******@hotmail.com> wrote in message news:uV**************@TK2MSFTNGP11.phx.gbl... Larry,
i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below,
it finds the correct number of cities in the xml file, but repeats the
first one 3 times. I'm sure its something minor but i just cant seem to figure it out.
here is the XML, and source code below:
--------------------XML--------------------- <?xml version="1.0" encoding="utf-8"?> <weatherFeed> <city> <currentConditions> country>Austria</country> <city>Vienna</city> <weatherImageURL>weather/lrg/sunny.gif</weatherImageURL> <celcius>1°C</celcius> <farenheit>34°F</farenheit> <description>Sunny</description> <relativeHumidity>69%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:37 AM</sunrise> <sunset>4:32 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-4°C</lowCelcius> <highFarenheit>33°F</highFarenheit> <lowFarenheit>24°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-6°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>21°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>25°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-2°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>28°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <country>Austria</country> <city>Innsbruck</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>74%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:55 AM</sunrise> <sunset>4:56 PM</sunset> <barometricPressure>30.13Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>10°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-6°C</highCelcius> <lowCelcius>-15°C</lowCelcius> <highFarenheit>22°F</highFarenheit> <lowFarenheit>5°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>26°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>27°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <!--URL:
http://weather.cnn.com/weather/forecast.jsp?locCode=LOWS--> <country>Austria</country> <city>Salzburg</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>86%</relativeHumidity> <wind>NNW at 2 mph (3 km/h)</wind> <sunrise>7:50 AM</sunrise> <sunset>4:48 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-5°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>23°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>2°C</highCelcius> <lowCelcius>-9°C</lowCelcius> <highFarenheit>35°F</highFarenheit> <lowFarenheit>15°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>24°F</highFarenheit> <lowFarenheit>11°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>3°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>3°C</highCelcius> <lowCelcius>0°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>32°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> </weatherFeed>
----------------SOURCE CODE----------------- Dim xDoc As New XmlDocument Dim xe_weatherFeed As XmlElement Dim xe_city As XmlNode Dim xe_currentConditions As XmlElement Dim xe_currentConditionsChild As XmlNode Dim xe_fiveDayForecast As XmlElement Dim xe_fiveDayForecastDay As XmlElement Dim xe_fiveDayForecastDayDetails As XmlNode
Try Dim a() As String Dim al As New ArrayList Dim i As Integer
xDoc.Load(strBaseURL & "weather/" & Request.QueryString("countryID") & ".xml") xe_weatherFeed = xDoc.SelectSingleNode("/weatherFeed") xe_city = xDoc.SelectSingleNode("/weatherFeed/city") xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions") xe_fiveDayForecast = xDoc.SelectSingleNode("/weatherFeed/city/fiveDayForecast")
For Each xe_city In xe_weatherFeed.ChildNodes If xe_city.NodeType = XmlNodeType.Element Then ReDim Preserve a(41) i = 0 For Each xe_currentConditionsChild In xe_currentConditions.ChildNodes If xe_currentConditionsChild.NodeType = XmlNodeType.Element Then a(i) =
xe_currentConditionsChild.InnerText i += 1 End If Next
For Each xe_fiveDayForecastDay In xe_fiveDayForecast For Each xe_fiveDayForecastDayDetails In xe_fiveDayForecastDay If xe_fiveDayForecastDayDetails.NodeType
= XmlNodeType.Element Then a(i) = xe_fiveDayForecastDayDetails.InnerText i += 1 End If Next Next al.Add(a) End If Next weatherRepeater.DataSource = al weatherRepeater.DataBind() Catch err As Exception Response.Write("<br><font color=red><b>" & err.Message & "</b></font>") Finally xDoc = Nothing End Try
thanks in advance
Paul.
Paul,
Good deal, Paul. The more you work with it, the more it will sense. I'm
glad the examples helped.
Larry
"Paul M" <mi******@hotmail.com> wrote in message
news:O$**************@tk2msftngp13.phx.gbl... Hi Larry,
thanks for that. As hard as i was staring at the code i didnt realise that the SelectSingleNode method was always referencing xDoc instead of
xe_city. Everything is working exactly as i want now. Many thanks again for your help and i appreciate the time you've taken to help me out with your useful responses.
regards, Paul.
"LarryR" <me@somewhere.com> wrote in message news:r4SOb.7359$dd6.3614@lakeread02... Hi Paul,
I think I see why you getting the first city 3 times. It has to do
with your how you are using the xpath expression to assign the variable xe_CurrentConditions.
xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions") Your xpath expression is always returns the 1st occurence of the currentConditions element because your search is always occuring from
the top level xml element reference, xDoc.
Try moving the assignment of xe_CurrentConditions after your
> For Each xe_city In xe_weatherFeed.ChildNodes
and change the statement to read:
xe_CurrentConditions = xe_City.SelectSingleNode("currentConditions")
That way your are getting the current conditions child relative to the current iteration of xe_city rather than always the first one.
If you are using Visual Studio and have the debugger available to you, examine the values of the variables as you step through the program. It will lend a lot of insight to what is happening.
LarryR
"Paul M" <mi******@hotmail.com> wrote in message news:uV**************@TK2MSFTNGP11.phx.gbl... Larry,
i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below, it finds the correct number of cities in the xml file, but repeats the first one 3 times. I'm sure its something minor but i just cant seem to
figure it out.
here is the XML, and source code below:
--------------------XML--------------------- <?xml version="1.0" encoding="utf-8"?> <weatherFeed> <city> <currentConditions> country>Austria</country> <city>Vienna</city> <weatherImageURL>weather/lrg/sunny.gif</weatherImageURL> <celcius>1°C</celcius> <farenheit>34°F</farenheit> <description>Sunny</description> <relativeHumidity>69%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:37 AM</sunrise> <sunset>4:32 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-4°C</lowCelcius> <highFarenheit>33°F</highFarenheit> <lowFarenheit>24°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-6°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>21°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>25°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-2°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>28°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <country>Austria</country> <city>Innsbruck</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>74%</relativeHumidity> <wind>N at 1 mph (2 km/h)</wind> <sunrise>7:55 AM</sunrise> <sunset>4:56 PM</sunset> <barometricPressure>30.13Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <!--5 Day Weather Forecast--> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>-2°C</highCelcius> <lowCelcius>-8°C</lowCelcius> <highFarenheit>29°F</highFarenheit> <lowFarenheit>17°F</lowFarenheit> <imageURL>weather/med/partly.cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>10°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-6°C</highCelcius> <lowCelcius>-15°C</lowCelcius> <highFarenheit>22°F</highFarenheit> <lowFarenheit>5°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>26°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>1°C</highCelcius> <lowCelcius>-3°C</lowCelcius> <highFarenheit>34°F</highFarenheit> <lowFarenheit>27°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> <city> <currentConditions> <!--URL: http://weather.cnn.com/weather/forecast.jsp?locCode=LOWS--> <country>Austria</country> <city>Salzburg</city> <weatherImageURL>weather/lrg/mostly.cloudy.gif</weatherImageURL> <celcius>0°C</celcius> <farenheit>32°F</farenheit> <description>Mostly Cloudy</description> <relativeHumidity>86%</relativeHumidity> <wind>NNW at 2 mph (3 km/h)</wind> <sunrise>7:50 AM</sunrise> <sunset>4:48 PM</sunset> <barometricPressure>30.1Hg (F)</barometricPressure> <lastUpdated>1/19/2004 4:01:12 AM</lastUpdated> </currentConditions> <fiveDayForecast> <Day1> <day>Monday</day> <highCelcius>0°C</highCelcius> <lowCelcius>-5°C</lowCelcius> <highFarenheit>32°F</highFarenheit> <lowFarenheit>23°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day1> <Day2> <day>Tuesday</day> <highCelcius>2°C</highCelcius> <lowCelcius>-9°C</lowCelcius> <highFarenheit>35°F</highFarenheit> <lowFarenheit>15°F</lowFarenheit> <imageURL>weather/med/snow.gif</imageURL> </Day2> <Day3> <day>Wednesday</day> <highCelcius>-4°C</highCelcius> <lowCelcius>-12°C</lowCelcius> <highFarenheit>24°F</highFarenheit> <lowFarenheit>11°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day3> <Day4> <day>Thursday</day> <highCelcius>3°C</highCelcius> <lowCelcius>1°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>33°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day4> <Day5> <day>Friday</day> <highCelcius>3°C</highCelcius> <lowCelcius>0°C</lowCelcius> <highFarenheit>37°F</highFarenheit> <lowFarenheit>32°F</lowFarenheit> <imageURL>weather/med/cloudy.gif</imageURL> </Day5> </fiveDayForecast> </city> </weatherFeed>
----------------SOURCE CODE----------------- Dim xDoc As New XmlDocument Dim xe_weatherFeed As XmlElement Dim xe_city As XmlNode Dim xe_currentConditions As XmlElement Dim xe_currentConditionsChild As XmlNode Dim xe_fiveDayForecast As XmlElement Dim xe_fiveDayForecastDay As XmlElement Dim xe_fiveDayForecastDayDetails As XmlNode
Try Dim a() As String Dim al As New ArrayList Dim i As Integer
xDoc.Load(strBaseURL & "weather/" & Request.QueryString("countryID") & ".xml") xe_weatherFeed = xDoc.SelectSingleNode("/weatherFeed") xe_city = xDoc.SelectSingleNode("/weatherFeed/city") xe_currentConditions = xDoc.SelectSingleNode("/weatherFeed/city/currentConditions") xe_fiveDayForecast = xDoc.SelectSingleNode("/weatherFeed/city/fiveDayForecast")
For Each xe_city In xe_weatherFeed.ChildNodes If xe_city.NodeType = XmlNodeType.Element Then ReDim Preserve a(41) i = 0 For Each xe_currentConditionsChild In xe_currentConditions.ChildNodes If xe_currentConditionsChild.NodeType = XmlNodeType.Element Then a(i) = xe_currentConditionsChild.InnerText i += 1 End If Next
For Each xe_fiveDayForecastDay In xe_fiveDayForecast For Each xe_fiveDayForecastDayDetails In xe_fiveDayForecastDay If
xe_fiveDayForecastDayDetails.NodeType = XmlNodeType.Element Then a(i) = xe_fiveDayForecastDayDetails.InnerText i += 1 End If Next Next al.Add(a) End If Next weatherRepeater.DataSource = al weatherRepeater.DataBind() Catch err As Exception Response.Write("<br><font color=red><b>" & err.Message
& "</b></font>") Finally xDoc = Nothing End Try
thanks in advance
Paul.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Trevor Best |
last post by:
I did a test once using a looping variable, first dimmed as Integer,
then as Long. I found the Integer was quicker at looping. I knew this to
be true back in the 16 bit days where the CPU's (80286)...
|
by: Tim |
last post by:
Hi,
I'm very new to .NET and am programming in C#. I have a web application
where i have two list boxes. Its kind of like a shopping card where you can
add items from one 'locations' list box to...
|
by: VB Programmer |
last post by:
Here's the code:
For Each li As ListItem In Me.lstAssignedEmailAddresses.Items
If li.Selected = True Then
Me.lstAssignedEmailAddresses.Items.Remove(li)
End If
Next
When I remove an item I get...
|
by: Bart Van Hemelen |
last post by:
The situation: I have a CheckBoxList cblTest, the items are disabled in
cblTest_DataBound in a foreach (ListItem oItem in cblTest.Items) loop.
I provide a link that calls a client-side JavaScript...
|
by: Mr. SweatyFinger |
last post by:
Given this:
***************************
For Each entryName In Request.Form
Response.Write("Name: " & entryName & "<br/>")
Response.Write("Value: " & Request.Form(entryName) & "<br/>")
...
|
by: olud |
last post by:
Hi All,
I am trying to insert selected contents of a listbox into a database by looping through the collection. The loop is working and the contents are going into the database. Starnge thing is...
|
by: LLM |
last post by:
Ok I fill a CheckedListBox this way
clbRoles.DataSource = objSecurity.ReturnRoleList();
clbRoles.DisplayMember = "RoleName";
clbRoles.ValueMember =...
|
by: adiel_g |
last post by:
I am trying to loop through a repeater to retrieve a dataitem field
but am getting a NullReferenceException.
I can find a checkbox control but cannot find a dataitem field. Here
is the code that...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |