问题描述
<?xmlversion="1.0"encoding="UTF-8"?>-<root>-<setting><itemname="pageCount">20</item><itemname="pageCountList">5;10;20;50;100</item></setting>-<metadatacategory="grid">-<rowsname="grid1">-<head><columnid="tba_gescod.c_gesnum"hideFlag="false"type="ro"sort="str"width="120">客户代码</column><columnid="tba_gescod.c_gesnam"hideFlag="false"type="ro"sort="str"width="120">客户名称</column><columnid="tba_gescod.c_reg"hideFlag="false"type="ro"sort="str"width="120">所属地区</column><columnid="tba_gescod.c_add"hideFlag="false"type="ro"sort="str"width="120">通信地址</column><columnid="tba_gescod.c_pos"hideFlag="false"type="ro"sort="str"width="120">邮政编码</column><columnid="tba_gescod.c_conmbl"hideFlag="false"type="ro"sort="str"width="120">公司电话</column><columnid="tba_gescod.c_tratel"hideFlag="false"type="ro"sort="str"width="120">传真号码</column><columnid="tba_gescod.c_eml"hideFlag="false"type="ro"sort="str"width="120">电子信箱</column><columnid="tba_gescod.c_setgesusr"hideFlag="false"type="ro"sort="str"width="80">建档人</column><columnid="tba_gescod.c_gestyp"hideFlag="false"type="ro"sort="str"width="120">客户类型</column><columnid="tba_gescod.c_geslev"hideFlag="false"type="ro"sort="str"width="120">客户等级</column><columnid="tba_gescod.c_gessrc"hideFlag="false"type="ro"sort="str"width="120">客户来源</column><columnid="tba_gescod.c_gesind"hideFlag="false"type="ro"sort="str"width="120">客户行业</column><columnid="tba_gescod.c_web"hideFlag="false"type="ro"sort="str"width="120">公司网址</column><columnid="tba_gescod.c_ecopro"hideFlag="false"type="ro"sort="str"width="120">经济性质</column><columnid="tba_gescod.c_bnkacc"hideFlag="false"type="ro"sort="str"width="120">银行帐户</column><columnid="tba_gescod.c_opnbnk"hideFlag="false"type="ro"sort="str"width="120">开户银行</column><columnid="tba_gescod.c_taxnum"hideFlag="false"type="ro"sort="str"width="120">税号</column><columnid="tba_gescod.c_hlpmrk"hideFlag="false"type="ro"sort="str"width="120">助记符</column><columnid="tba_gescod.c_setgesdat"hideFlag="false"type="ro"sort="str"width="120">建档时间</column><columnid="ta_regset.c_regnam"hideFlag="false"type="ro"sort="str"width="120">所属区域</column><columnid="tbr_geslikgoo.c_goo"hideFlag="false"type="ro"sort="str"width="120">感兴趣产品</column><columnid="tba_gesconman.c_connam"hideFlag="false"type="ro"sort="str"width="100">联系人姓名</column><columnid="tba_gesconman.c_condut"hideFlag="false"type="ro"sort="str"width="80">主联系人标志</column><columnid="tba_gesconman.c_condut"hideFlag="false"type="ro"sort="str"width="80">联系人职务</column><columnid="tba_gesconman.c_eml"hideFlag="false"type="ro"sort="str"width="120">联系人E-mail</column><columnid="tba_gesconman.c_othereml"hideFlag="false"type="ro"sort="str"width="120">联系人备用E-mail</column><columnid="tba_gesconman.c_confax"hideFlag="false"type="ro"sort="str"width="80">联系人传真</column><columnid="tba_gesconman.c_offtel"hideFlag="false"type="ro"sort="str"width="80">联系人电话</column><columnid="tba_gesconman.c_conmbl"hideFlag="false"type="ro"sort="str"width="80">联系人手机</column></head>-<rowid="LIGHT">-<cellrowspan="1">-<![CDATA[<ahref="javascript:void(0)"onClick=openModSubWin(encodeURI("../module/a0312_rgt_edit.jsp?formId=toUpd&gesnum=LIGHT&mid=a1ad048ac3cc73373fa2dfec4d1aa8c2"))>LIGHT</a>]]></cell>-<cellrowspan="1">-<![CDATA[<ahref="javascript:void(0)"onClick=openModSubWin(encodeURI("../module/a0312_rgt_edit.jsp?formId=toUpd&gesnum=LIGHT&mid=a1ad048ac3cc73373fa2dfec4d1aa8c2"))>LightHausPhotonicsPteLtd</a>]]></cell><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"/><cell>Terence</cell><cell>Y</cell><cell/><cell></cell><cell/><cell/><cell></cell><cell/></row>-<rowid="NOVA">-<cellrowspan="1">-<![CDATA[<ahref="javascript:void(0)"onClick=openModSubWin(encodeURI("../module/a0312_rgt_edit.jsp?formId=toUpd&gesnum=NOVA&mid=f4eb0d9d078245c581dff1338f749b49"))>NOVA</a>]]></cell>-<cellrowspan="1">-<![CDATA[<ahref="javascript:void(0)"onClick=openModSubWin(encodeURI("../module/a0312_rgt_edit.jsp?formId=toUpd&gesnum=NOVA&mid=f4eb0d9d078245c581dff1338f749b49"))>NaimElectric</a>]]></cell><cellrowspan="1">LB</cell><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"></cell><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1"/><cellrowspan="1">2016-03-2417:22:30.726</cell><cellrowspan="1"></cell><cellrowspan="1"/><cell></cell><cell></cell><cell/><cell></cell><cell/><cell/><cell></cell><cell/></row></rows></metadata>-<setting><itemname="totalcount">2</item></setting></root>
解决方案
解决方案二:
你的xml格式都有问题,这个分明是一个展示出来的grid,而且里面的column的id都是重复的,XElementroot=XElement.Load(path);varrows=root.Element("metadata").Element("rows");DataTabledt=newDataTable();foreach(varcolumninrows.Element("head").Elements("column")){dt.Columns.Add(column.Value);}foreach(varrowinrows.Elements("row")){dt.Rows.Add(row.Elements("cell").Select(c=>c.Value).ToArray());}Console.WriteLine(dt.Rows.Count);
解决方案三:
引用1楼starfd的回复:
你的xml格式都有问题,这个分明是一个展示出来的grid,而且里面的column的id都是重复的,XElementroot=XElement.Load(path);varrows=root.Element("metadata").Element("rows");DataTabledt=newDataTable();foreach(varcolumninrows.Element("head").Elements("column")){dt.Columns.Add(column.Value);}foreach(varrowinrows.Elements("row")){dt.Rows.Add(row.Elements("cell").Select(c=>c.Value).ToArray());}Console.WriteLine(dt.Rows.Count);
感谢大神,这个是JSP文件查询后的结果,显示在网页上的grid。我先试下。
解决方案四:
引用1楼starfd的回复:
你的xml格式都有问题,这个分明是一个展示出来的grid,而且里面的column的id都是重复的,XElementroot=XElement.Load(path);varrows=root.Element("metadata").Element("rows");DataTabledt=newDataTable();foreach(varcolumninrows.Element("head").Elements("column")){dt.Columns.Add(column.Value);}foreach(varrowinrows.Elements("row")){dt.Rows.Add(row.Elements("cell").Select(c=>c.Value).ToArray());}Console.WriteLine(dt.Rows.Count);
为啥行数少了很多呢。
解决方案五:
哦,知道了,分页的原因,爬虫只爬了一页,再次感谢。