现在有一个xml文件,里面的文件元素为
<ROWDATA>
     <ROW GTHCODE="00040100" RECDATE="20050613" ICN="5100000125585490" TIM="20050611211349" /> 
……
……
……
</ROWDATA>TIM是string类型
现在想获得TIM的前8位,然后转换为如2005-6-12这样的日期,与RECDATE比较
不知道TIM的前8位怎么取??if(oNodeList[i].Attributes["TIM"] != null)
{
strRecDate = "'" + convertDate(oNodeList[i].Attributes["TIM".Substring(0,8)].Value.ToString()) + "'";
}
else
{
strRecDate = "null"; }这样写对嘛?

解决方案 »

  1.   

    convertDate(oNodeList[i].Attributes["TIM"].Value.ToString().Substring(0,8))
      

  2.   

    还是应该是这样的?if(oNodeList[i].Attributes["TIM"] != null)
    {
    strRecDate = "'" + convertDate(oNodeList[i].Attributes["TIM"].Value.ToString()".Substring(0,8)) + "'";
    }
    else
    {
    strRecDate = "null";
    }
      

  3.   

    if(oNodeList[i].Attributes["TIM"] != null)
    {
    strRecDate = "'" + convertDate(oNodeList[i].Attributes["TIM"].Value.ToString()".Substring(0,8)) + "'";
    }
    else
    {
    strRecDate = "null";
    }
      在Value.ToString()"这为什么要加一个"啊
      

  4.   

    如果你能够从xml中正确的把数据读出来的话就可以用
    strRecDate = convertDate(oNodeList[i].Attributes["TIM"].Value.ToString().Substring(0,8));
    如果strRecDate是一个string类型的话