中间的空格是什么? TAB键吗?

解决方案 »

  1.   

    用IO类中函数取出.txt中的值,for循环读出.txt中的值。
    这样:
    for(int i=0;i<=this.listBox2.Items.Count-1;i++)
    {
    strItem=this.listBox2.Items[i].ToString();
    for(int a=0;a<=strItem.Length-1;a++)
    {
    strTable+=strItem[a];
    if(char.IsWhiteSpace(strItem[a]))

    strTable="";
    break;
    }

    }
    }以上的我是用for读出ListBox中的值:LZ    刘宗    A试试上面的
      

  2.   

    xml文件是这样写的,我就不写读取数据了,你先读出这些行,取到每个数据
    Import System.XMLdim writer as XMLTextWriter
    try
      writer = new XMLTextWriter(Server.MapPath("a.xml"),nothing)
      writer.Formatting = Formatting.Indented
      writer.Indentation = 3  
      writer.WriteStartElement("Info")
        while(txt文件没结束//可以用txtReader.Peek()>-1判断)
          '读出txt文件的一行,假设将每个参数存在数组info中,从Info(0)开始
          writer.StartElement("Info_mx")
            writer.WriterElementString("nss",info(0))
            writer.WriterElementString("nsa",info(1))
            writer.WriterElementString("nsr",info(2))
            writer.WriterElementString("nsj",info(3))
            writer.WriterElementString("nsje",info(4))
          writer.WriterEndElement()      
        end while
       writer.WriterEndElement()
       writer.Flush
    catch e as Exception
        Response.Writer("Error accessing XML file")
    finally
        writer.Close
        Response.Writer("Finished!")
    end try我这里没有.net,所以没经过调试,提供一点思路,希望能有所帮助
      

  3.   

    要为空不写那一项,可以在info数组遍历的时候加个判断就行了
      

  4.   

    string path = Server.MapPath("aa.txt");
    FileInfo aa = new FileInfo(path);
    StreamReader objS=aa.OpenText();
    string str=objS.ReadToEnd();
    string[] ary = str.Split(new char[]{'\n'});
    string res ="<Info>\n";
    string[] flag = new string[]{"nss>","nsa>","nsr>","nsj>","nsje>"};
    for (int i=0;i<ary.Length;i++)
    {
    if (ary[i].Trim().Length>0)
    {
    res +="<Info_mx>"; string[] ary1 = ary[i].Trim().Split(new char[]{'\t'});
    for (int j=0;j<ary1.Length;j++)
    {
    res +="<"+ flag[j] +ary1[j].Trim() +"</"+ flag[j] ;
    }
    res +="</Info_mx>\n";
    }
    }
    res +="</Info>";
    res = "<xml version=\"1.0\" encoding=\"gb2312\">\n"+res +"</xml>";
    FileInfo bb = new FileInfo(Server.MapPath("aa.xml"));
    StreamWriter newStream =  bb.CreateText();
    newStream.Write(res);
    newStream.Close();
    newStream =null;
    bb = null;
    aa = null;
    objS.Close();
    objS = null;