Paip. obtain data from HTML select

Source: Internet
Author: User

Paip. obtain data from HTML select

Recently .. There is a withdrawal module. You need to SELECT a bank from the SELECT control .. But the obtained ID value. The bank name must be saved in the background ..


The select html is as follows ..

<SELECT id = Land_Bank
Name = Land_Bank require = "true" msg = "select a bank" operator = "GreaterThan" to = "0" rig = "select a bank"
DataType = "Compare"> <OPTION selected value = 0> select a bank </OPTION> <OPTION
Value = 4> Industrial and Commercial Bank of China </OPTION> <OPTION value = 5> Agricultural Bank of China </OPTION> <OPTION
Value = 12> China Construction Bank </OPTION> <OPTION value = 6> Bank of Communications </OPTION> <OPTION
Value = 9> Bank of China </OPTION> <OPTION value = 30> China Postal Savings Bank </OPTION> <OPTION
Value = 16> China Merchants Bank </OPTION> <OPTION value = 33> China Pudong Development Bank </OPTION> <OPTION
Value = 19> China Citic Bank </OPTION> <OPTION value = 17> China Minsheng Bank </OPTION> <OPTION
Value = 15> Industrial Bank </OPTION> <OPTION value = 13> China Everbright Bank </OPTION> <OPTION
Value = 8> bank of Beijing </OPTION> <OPTION value = 21> bank of Guangzhou </OPTION> <OPTION
Value = 31> Shenzhen Development Bank </OPTION> <OPTION value = 20> Guangdong Development Bank </OPTION> <OPTION
Value = 22> bank of Hangzhou </OPTION> <OPTION value = 27> bank of Ningbo </OPTION> <OPTION
Value = 25> Huaxia Bank </OPTION> <OPTION value = 29> Ping An Bank </OPTION> <OPTION
Value = 18> zheshang bank </OPTION> <OPTION value = 11> Bohai Bank </OPTION> </SELECT>

How to obtain the ID value in select html becomes a problem...

First, I want to use XML to obtain it, but the HTML is not very strict and does not meet the XML conditions .. In the end, my idea is to convert HTML into XML and then use XML to get the. NET version.

HTML Parser library using Winista. Text. HtmlParser;

------------ Detailed design (pseudo code )--------------
1. Save HTML to/banks.txt
2. html = read (curdir + "/banks.txt ")
Xml = convert (html)
Nodelist = getlistByTagname (xml, "option ")
Foreach nodelist
If (node. value = bankid)
Return node.txt

----------------- Actual code ----------------

Private string getbankname (string bankId)
String rootdir = System. Web. HttpContext. Current. Request. PhysicalApplicationPath;
String xmldir = rootdir + "/pay/banks.txt ";
String html = m. filex. read (xmldir, "gbk ");
String xmlstr = m. xml. XMLHelper. CovertHtmlToXml (html, "OPTION ");
// XmlDataDocument xmlDoc = new System. Xml. XmlDataDocument ();
// XmlDoc. LoadXml (xmlstr );
String bname = getbankname (xmlstr, bankId );
Return bname;
// Return "nothisbank ";


Private string getbankname (string xmlstr, string bank)

XmlDataDocument xmlDoc = new System. Xml. XmlDataDocument ();

XmlDoc. LoadXml (xmlstr );

XmlNodeList list = xmlDoc. GetElementsByTagName ("OPTION ");
Foreach (XmlNode node in list)
String val = node. Attributes ["VALUE"]. Value;
String text = node. InnerText;
If (bank. Equals (val ))
Return text;

Return "nothisbank ";


Author: attilax

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.