zoukankan      html  css  js  c++  java
  • C++ 读取XML 和TXT

    一 。TXT 部分

     1 #include <iostream>
     2 #include <fstream>
     3 #include <sstream>
     4 #include <vector>

    7 //split a string; 8 void StringSplit(std::string source_str,std::vector<std::string> &dest_str_list,std::string SplitChar) 9 { 10 int comma_n = 0; 11 do 12 { 13 std::string tmp_s = ""; 14 comma_n = source_str.find(SplitChar); 15 if( -1 == comma_n ) 16 { 17 tmp_s = source_str.substr( 0, source_str.length() ); 18 dest_str_list.push_back( tmp_s ); 19 break; 20 } 21 tmp_s = source_str.substr( 0, comma_n ); 22 source_str.erase( 0, comma_n+1 ); 23 dest_str_list.push_back( tmp_s ); 24 } 25 while(true); 26 } 27 28 int main() 29 { 30 31 string fileName="input.txt"; 32 ifstream fin(fileName); 33 if (fin.fail()) 34 { 35 return -1; 36 } 37 38 //fin.open(fileName); 39 while(!fin.eof()) 40 { 41 string line; 42 getline(fin,line); 43 vector<string> List; 44 StringSplit(line,List," "); 45 for (vector<string>::iterator it=List.begin();it!=List.end();it++) 46 { 47 cout<<*it<<endl; 48 } 49 //cout<<line<<endl; 50 } 51 system("pause"); 52 return 0; 53 }

    二。XML部分

       采用的是tinyXML来解析文档。

      代码元旦后再贴。在公司- - 

       

  • 相关阅读:
    hdoj 2041 超级楼梯
    hdoj 刚入门~把11页A了一些~~
    编写Powerdesigner脚本,快速生成数据库表
    网站
    duwamish
    面试题
    http://www.sqlclub.com
    Microsoft PetShop 3.0 设计与实现数据访问层
    Java代码查询站点
    从Blog上面去掉那该死的“狗狗订阅”的logo !
  • 原文地址:https://www.cnblogs.com/karcylee/p/3476277.html
Copyright © 2011-2022 走看看