ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 11th, 2003, 06:15 AM
homerdooh homerdooh is offline
php newbie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2001
Posts: 514 homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 7 sec
Reputation Power: 11
variable dissapearing!

Hi,
I'm using ASP to retrieve simple information from an XML file. I set a variable on the asp page that gets the information from XML if they match.

It is supposed to write out the answer but for some reason the variable on the asp page is not matching the value on the XML page even though they are the same.
Code:
<% 
Var1 = 3 
response.write "CD: " 
response.write Var1 & "<BR>"

' open xml file to compare

Set objXML = Server.CreateObject("Microsoft.XMLDOM") 
objXML.async = False 
objXML.Load(Server.MapPath("check.xml")) 
Set objLst = objXML.getElementsByTagName("list") 
intNoOfHeadlines = objLst.length 
For i = 0 To intNoOfHeadlines-1
'the code below is not matching
if objLst.item(i).childNodes(0).text = Var1 then 
response.write objLst.item(i).childNodes(1).text 
response.write " category is selected" 

end if 
Next 
%> 


the xml file
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> 
<Menu> 
<list> 
<cd>1</cd> 
<category>6</category> 
</list> 
<list> 
<cd>2</cd> 
<category>6</category> 
</list> 
<list> 
<cd>3</cd> 
<category>7</category> 
</list> 
<list> 
<cd>4</cd> 
<category>8</category> 
</list> 
</Menu>


Var1 = 3 and there is a tag with value 3 in the xml so its suposed to print out childnode(1) which is 7.

The weird thing is if i use the line
Code:
if objLst.item(i).childNodes(0).text = 3 
instead of
Code:
  
if objLst.item(i).childNodes(0).text = Var1 

it works but i want to be able to have the value in a variable.

Can anyone help? Thanks.
__________________
"They have the internet on computers now" - Homer

Reply With Quote
  #2  
Old March 21st, 2003, 12:47 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
The reason you are not getting a match is that the statement

Var1 = 3

sets Var1 to numeric 3, whereas the string you are comparing to is text. Numeric 3 and text 3 are not the same. So try one of the following, declare Var1 as text by using

Var1 = "3"

Or try accessing Var1 as text using

Var1.text

One of these should work.
__________________
How can I soar like an eagle when
I'm flying with turkey's?

Reply With Quote
  #3  
Old March 26th, 2003, 05:22 AM
homerdooh homerdooh is offline
php newbie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2001
Posts: 514 homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level)homerdooh User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 7 sec
Reputation Power: 11
Thanks man! it works.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > variable dissapearing!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway