Hello. I have recently completed a program that uses a web service to define vocabulary words. Now I'm adding the ability to first check whether each word is spelled correctly before using the web service to define it.
So, I am using the following code to get an XML stream containing spelling suggestions:
================================================== =================
//Use web service to check spelling
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://ws.cdyne.com/SpellChecker/check.asmx/CheckTextBody");
string postsourcedata;
postsourcedata = "BodyText=" + word + "&LicenseKey=" + licenseKey;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postsourcedata.Length;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
Stream writeStream = request.GetRequestStream();
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(postsourcedata);
writeStream.Write(bytes, 0, bytes.Length);
writeStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);
string page = readStream.ReadToEnd();
XmlDocument doc = new XmlDocument();
doc.LoadXml(page);
XmlNode root = doc.DocumentElement;
//PROBLEM HERE; HOW TO DISPLAY A SINGLE "SUGGESTIONS" ELEMENT
MessageBox.Show(root. .ToString());
================================================== ====================
You can see a sample of the XML file returned at this address:
http://ws.cdyne.com/SpellChecker/che...enseKey=string
For now, I'm just going to show all possible spelling suggestions, if any, in a MessageBox, before I worry about allowing the user to select the one they wish to use. However, as my comments suggest, how can I go about getting the value of a single <Suggestions> element? I know how to get the InnerText of the entire document (root.ParentNode["DocumentSummary"].InnerText.ToString()), but I need to be able to offer each suggestion one at a time! Please and thanks for your help!
Computers will never surpass the human brain; no computer will ever be able to replicate human stupidity.