如何将返回结果处理一下,分别输出(即读取有用节点的数据)
//Create a 'WebRequest' object with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://fanyi.youdao.com/openapi.do?keyfrom=mytranslator1234&key=1501976072&type=data&doctype=xml&version=1.1&q=hello"); //Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream strm = myWebResponse.GetResponseStream();
StreamReader reader = new StreamReader(strm);
string str = reader.ReadToEnd();
Console.Write(str);
myWebResponse.Close();
Console.ReadKey();
thanks!
thanks!
thanks!
再thanks!
//Create a 'WebRequest' object with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://fanyi.youdao.com/openapi.do?keyfrom=mytranslator1234&key=1501976072&type=data&doctype=xml&version=1.1&q=hello"); //Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream strm = myWebResponse.GetResponseStream();
StreamReader reader = new StreamReader(strm);
string str = reader.ReadToEnd();
Console.Write(str);
myWebResponse.Close();
Console.ReadKey();
thanks!
thanks!
thanks!
再thanks!
translation节点:译文
basic节点:英标和基本解释
web节点是一些网络解释。
XmlDocument xmlDoc = new XmlDocument();//xml document
xmlDoc.LoadXml("XXXXXXXXXXXXXXXXXXX"); XDocument xDoc = XDocument.Parse("XXXXXXXXXXXXXXXX");linq to xml
你大概可以用上面2中方式来加载xml(XXXXX是你的查询结果)
然后读取xml内容就可以了
麻烦代码,thanks
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(有道返回的XML)你可以根据你要的节点进行处理。例如 XodeList
SelectSingleNode(...)
SelectSingleNodes(...)
InnerText
InnerXml