如何使用C#读取TD的值? [英] How to use C# read the value of the TD?

查看:317
本文介绍了如何使用C#读取TD的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我们的CMIS(计算机管理信息系统)服务器页面:(注意:我无法修改的CMIS服务器,该页面是自动生成的.)

This is our CMIS(Computer Management Information System) Server page: (Note: The CMIS server I cannot modify, the page is automatic generation.)

<form method="POST" action="bl_view_invoice_controler.jsp" name="fm1"  önSubmit="return checkValid()"> //please attention the form name is 'fm1'
      <TABLE id=AutoNumber7 style="BORDER-COLLAPSE: collapse" 

                      borderColor=#111111 cellSpacing=0 cellPadding=2 width="100%" 

                      border=0>
                        <TBODY>
                        <TR>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                        </TR>
    <TR>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                        </TR>
                          </TBODY></TABLE>
    <script language="JavaScript"> //this script store the value of the table
                    fm1.ivcd_item['0'].value="B747-400";
                    fm1.ivcd_totalfc['0'].value="500.00";
                    fm1.ivcd_unitprice['0'].value="1";
                    fm1.ivcd_quantity['0'].value="";

                    fm1.ivcd_item['2'].value="B747-800";
                    fm1.ivcd_totalfc['2'].value="250.00";
                    fm1.ivcd_unitprice['2'].value="";
                    fm1.ivcd_quantity['2'].value="";
     </script>          
    </FORM>



我的问题是,如何使用C#获取表的值,将其称为"B747-400"或"B747-800"?我的想法是使用BHO(浏览帮助器对象),但是该怎么做?



My question is, How to use C# get the value of the table, suach as ''B747-400'' or ''B747-800''? My idea is use BHO(Browse Helper Object), but How to do?

推荐答案

这并不容易.解析XML很容易,将XML解析为XDocument:

This is not going to be easy. It is easy enough to parse the XML parsing the XML into a XDocument:

string str =
@"
<!-- comment at the root level -->
<root>
    <child>Content</child>
</root>";
XDocument doc = XDocument.Parse(str);



这将允许您使用以下
获取xml中的所有信息,包括脚本标签的内容.



This will allow you to get to all the information in the xml, including the content of the script tag by using the following

child = doc.Descendants("Child").FirstOrDefault();
Console.WriteLine(child.Value);



不幸的是,仍然必须解析脚本标签的内容.这将需要您进行认真的工作.我建议使用正则表达式.我不是使用正则表达式的专家,它将需要一些花哨的东西来进行提取,但是我已经看到一些使用正则表达式的真正整洁的东西,例如,使用正则表达式的C#公式计算器(http://www.jarloo.com/c-formula-evaluator [



Unfortunately, still have to parse the content of the script tag. That will require you to go through and do the hard work. What I recommend is to use regular expressons. I am not an expert at working with regular experssions, and it is going to require some fancy stuff to do the extraction, but I have seen some really neat stuff with regular expressons, for instance C# Formula Evaluator using Regular Expressions (http://www.jarloo.com/c-formula-evaluator[^]). You will have to read up on regular expressons.


您可以使用

这篇关于如何使用C#读取TD的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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