这是一个table块,我想得到最外层,有多少个td,如何?谢谢。
<table border= "0 " width= "100% " id= "table16 " cellpadding= "2 ">
<tr>
<td> [m.v.sub.title{0}.link{0}.normal] </td>
<td>
<table border= "1 " width= "100% " id= "table17 " cellpadding= "2 " style= "border-collapse: collapse ">
<tr>
<td width= "16 "> </td>
<td> [m.v.sub.title{0}.link{0}.normal] </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border= "1 " width= "100% " id= "table18 " cellpadding= "2 " style= "border-collapse: collapse ">
<tr>
<td width= "16 "> </td>
<td> [m.v.sub.title{0}.link{0}.normal] </td>
</tr>
</table>
</td>
<td>
<table border= "1 " width= "100% " id= "table19 " cellpadding= "2 " style= "border-collapse: collapse ">
<tr>
<td width= "16 "> </td>
<td> [m.v.sub.title{0}.link{0}.active] </td>
</tr>
</table>
</td>
</tr>
</table>
这是一个table块,我想得到最外层,有多少个td,如何?谢谢。
------解决方案--------------------你用XML去分析就可以了如:
int tdCount = 0;
XmlDocument docTable = new XmlDocument();
docTable.LoadXml( " <table .../> ");
foreach(XmlNode tr in docTable.ChildNodes) {
foreach(XmlNode td in tr.ChildNodes) {
++ tdCount;
}
}
------解决方案--------------------上面说错了一下,没看清楚你的题,你只要得到td 的Count就可以了:
int tdCount = 0;
XmlDocument docTable = new XmlDocument();
docTable.LoadXml( " <table .../> ");
XmlNode outTable = docTable.SelectSigleNode(table);
foreach(XmlNode tr in outTable.ChildNodes) {
tdCount += tr.ChildNodes.Count;
}
------解决方案--------------------td: document.all.table16.cells.length;
tr: document.all.table16.rows.length