搜索在HttpWebresponse-C#表单元素 [英] search for form elements in HttpWebresponse-C#

查看:221
本文介绍了搜索在HttpWebresponse-C#表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTTPPPot其返回我捕捉使用:

I have a HTTPPPot whose return I capture using :

WebResponse webResponse = httpWebRequest.GetResponse();

Stream responseStream = webResponse.GetResponseStream();

StreamReader responseReader = new StreamReader(responseStream);

string responseString = responseReader.ReadToEnd();

在响应字符串,客户端返回以下

In the response string, the client returns the following

<input type="hidden" name="Location" value="sometext.txt"><input type="hidden" name="tableid" value="2"><input type="hidden" name="GroupID" value="1236781329">

根据以上情况,我需要得到每个表单元素的值。我不知道隐藏的表单元素的名称。是否有一个快速的方法来obatin这一点没有逐行读取整个响应线,确定该行包含我lookinng任何模式?

Based on the above, I need to obtain the values of each form element. I do know the names of the hidden form elements. Is there a quick way to obatin this without reading the entire response line by line and determining if the line contains any pattern that I am lookinng for?

推荐答案

我会用System.Xml.Linq的和解析响应到的XElement,并使用LINQ检索节点和属性的枚举列表。 LinqPad( http://www.linqpad.net/ )是一个伟大的工具来微调您的LINQ查询你把它粘贴到你的代码之前。

I would use System.Xml.Linq and parse the response into an XElement, and use LINQ to retrieve enumerated lists of nodes and attributes. LinqPad (http://www.linqpad.net/) is a great tool to fine-tune your LINQ queries before you paste it into your code.

这篇关于搜索在HttpWebresponse-C#表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆