Jump to content

code for random word generator w/xml file


Guest cjason

Recommended Posts

can anyone help me with a homework assignment? the assignment is to create a web page that pulls random words from an attached xml file.the layout of the xml file is: <words> <wordlist> <word lan="eng" diff="1">baby</word> <word lan="eng" diff="1">coffee</word> <word lan="eng" diff="2">spotlight</word> <word lan="eng" diff="3">ashtray</word> <word lan="sp" diff="2">casa</word> <word lan="sp" diff="3">aqua</word> <word lan="sp" diff="1">caliente</word> <word lan="fr" diff="3">celibataire</word> <word lan="fr" diff="2">saigner</word> <word lan="fr" diff="1">monsieur</word> </wordlist></words>the aspx file as a drop down list for language (english, spanish, french); a drop down list for difficulty (1, 2, 3); a button to click and a label for the random word to appear. this is the code i have so far for the aspx.vb fileProtected Sub difficulty_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles difficulty.SelectedIndexChanged End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strloc As String = "K:\hangman\words.xml" Dim :) As System.Xml.XmlDocument = New System.Xml.XmlDocument() Dim randObj As New Random() :).Load(strloc) Dim language As String = Dim difficulty As String = Dim thePath As String = "/Wordlist/word[@lan=eng and diff=1]" Dim resultNodes As System.Xml.XmlNodeList = :mellow:.SelectNodes(thePath) Dim randomIndex As Integer = randObj.Next(0, 10) Dim randomNode As System.Xml.XmlNode = resultNodes.Item(randomIndex) Me.Result.Text = randomNode.InnerText.ToString End SubEnd Class thanks to anyone that can give me any direction to this this assignment!! cjasoncideko@yahoo.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...