Current location: Hot Scripts Forums » Programming Languages » ASP.NET » multi value hashtable


multi value hashtable

Reply
  #1 (permalink)  
Old 02-14-06, 07:02 PM
minority minority is offline
Wannabe Coder
 
Join Date: Jun 2005
Posts: 145
Thanks: 0
Thanked 0 Times in 0 Posts
multi value hashtable

hey guys I have gotten myself confused..

I have got it to feed in the xml to the hash table and I have 2 keys which is correct...however is there away to count the number of values to each key? as when i do a search I am always recieving nothing...I have even tried search to see if it even contains the word in the value but it returns false any help would be great.

CODE

Code:
<%@ Page Language="VB" ContentType="text/html" Debug="true" Explicit="True"%>

<%@ Import Namespace="System.XML"%>

<%@ Import Namespace="System.IO"%>

<%@ Import Namespace="System.Data" %>

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>



<script language="VB" Runat="server">

dim Xread = new XMLTextReader(Server.MapPath("App_Data/XML/CommonWord.xml"))

dim CommonWord = New Hashtable

Dim arrName as new arraylist

Dim saying as String = "Tech"


Sub Page_Load()

dim y

For Each C As Char In saying.ToCharArray

If Char.IsLetterOrDigit(C) Then

y &= C

Else

If y <> "" Then

arrName.Add(y)

y = ""

End If

End If

Next

If y <> "" Then arrName.Add(y)

dim j

try

While xread.Read() ' Start of the xml reading

Select Case xread.NodeType

Case XMLNodeType.Element

if Xread.Name = "KeyWord" then

Word = Xread.ReadString()

response.write("KeyWord: " & Word & "<BR>")

CommonWord.Item(Word)

elseif Xread.Name = "Word"

response.write("Common Word: " & Xread.ReadString() & " of " & Word & "<BR>") 

CommonWord.Item(Word) = Xread.ReadString()

end if

End Select 

End While

Finally

xread.close()

End try

response.write("<br>-----------------------------<br><u><b>Total Size of Hashtable</b></u><br> <b>Number of Keys =</b>" & CommonWord.Count & "<br>-----------------------------<br>")

CommonWordRemoval()

end sub 

sub CommonWordRemoval()

dim CommonTerm as string

dim i, k as integer

dim j as integer = 0

i = arrName.count

Do Until j = i 

response.write("<br> Users Word: " & arrName(j) & "<br>")

CommonTerm = CommonWord.Item(arrName(j))

response.write("Has Common Word: " & CommonTerm & "<BR>")

j = j + 1 

Loop

end sub

</script>

</body>

</html>
HTML Code:

A visual picture of the out put for above code at the moment
Quote:
KeyWord: Technology
Common Word: Technological of Technology
Common Word: Tech of Technology
Common Word: Technology of Technology
KeyWord: Get
Common Word: Gets of Get
Common Word: Got of Get
Common Word: Gotten of Get

-----------------------------
Total Size of Hashtable
Number of Keys =2
-----------------------------

Users Word: Tech
Has Common Word:
Can you explain why this is happening as I am at a complete loss....I have checked there are keys in the hashtable but not sure about values as I am not sure how to output a hashtable so its viewable.



Thanks again for any help
Reply With Quote
  #2 (permalink)  
Old 03-01-06, 08:37 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Please provide a sample XML file and a sample table in order for your code to make sense. Without that information it is hard to guess the ins and outs of your system.
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Colors in a single hyperlink. mani786 CSS 0 10-01-05 02:14 PM
multi user statistics scripts >> HELP demo2 Script Requests 0 09-29-05 04:06 PM
Problem using listbox with multi selection set nidkil Windows .NET Programming 1 08-19-05 03:25 PM
multi sessions jahar PHP 2 05-25-05 02:24 PM
Re-arranging values in a multi select box.. fluff JavaScript 3 02-24-04 10:45 AM


All times are GMT -5. The time now is 01:08 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.