回答編集履歴
1
追記
test
CHANGED
@@ -1 +1,107 @@
|
|
1
1
|
ipadcaronさんの言うように、普通に文字列(string)として読み込んで,str.find("<P><p>");とかで見つければいいと思いますが?
|
2
|
+
|
3
|
+
[追記]
|
4
|
+
|
5
|
+
```cpp
|
6
|
+
|
7
|
+
~/test/cpptst >cat tst01.cpp
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
#include <iostream>
|
12
|
+
|
13
|
+
#include <fstream>
|
14
|
+
|
15
|
+
#include <string>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
using namespace std;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
bool strip(const string &ss);
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
int main()
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
string sbuf;
|
32
|
+
|
33
|
+
string stmp;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
ifstream inFile("./tst01.xml");
|
38
|
+
|
39
|
+
// ファイルから文字列を全て読む
|
40
|
+
|
41
|
+
while( getline(inFile,stmp)){
|
42
|
+
|
43
|
+
sbuf += stmp;
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
//
|
48
|
+
|
49
|
+
if( !sbuf.empty()){
|
50
|
+
|
51
|
+
(void)strip(sbuf);
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
//
|
56
|
+
|
57
|
+
return 0;
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
bool strip(const string &ss)
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
string::size_type sp= 0;
|
68
|
+
|
69
|
+
string::size_type ep= 0;
|
70
|
+
|
71
|
+
//
|
72
|
+
|
73
|
+
sp= ss.find("<p><p>");
|
74
|
+
|
75
|
+
if( sp == string::npos ){
|
76
|
+
|
77
|
+
// 見つからなかった;;
|
78
|
+
|
79
|
+
return false;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
sp += 6; // "<p><p>"をスキップ
|
84
|
+
|
85
|
+
ep= ss.find("</p></p>",sp);
|
86
|
+
|
87
|
+
//
|
88
|
+
|
89
|
+
if( ep != string::npos ){
|
90
|
+
|
91
|
+
// 終わりが見つかったら表示
|
92
|
+
|
93
|
+
cout << ss.substr(sp, ep-sp) << endl;
|
94
|
+
|
95
|
+
return true;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
//
|
100
|
+
|
101
|
+
return false;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
~/test/cpptst >
|
106
|
+
|
107
|
+
```
|