-- 作者:skyyks
-- 发布时间:12/22/2008 4:21:00 PM
-- tinyxml不能解析大文件?
我在用tinyxml解析rss文件的时候,为什么解析比较大的文件就会出现段错误呢?提示的错误是:No executable file specified.和Use the"file"or"exec-file"command.我的代码如下: #include <iostream> #include <fstream> #include "tinyxml.h" using namespace std; int main(int argc, char *argv[]) { string filename = "first.xml"; TiXmlDocument *doc = new TiXmlDocument; doc->LoadFile("first.xml"); const TiXmlElement* root = doc->RootElement(); const TiXmlNode *m=root->FirstChild(); const TiXmlElement *t = (const TiXmlElement*)m; for( const TiXmlNode*n= t->FirstChild();n; n=n->NextSibling()) { if(n->Type() == TiXmlNode::ELEMENT) { if((!strcmp(n->Value(),"title"))||(!strcmp(n->Value(),"description"))) { const TiXmlElement *f = (const TiXmlElement*)n; std::string mesh1 = f->GetText(); cout<< mesh1 <<endl; } else if(!strcmp(n->Value(),"item")) { const TiXmlElement *e = (const TiXmlElement*)n; for( const TiXmlNode* d=e->FirstChild();d; d=d->NextSibling()) { if(d->Type() == TiXmlNode::ELEMENT) { if((!strcmp(d->Value(),"title"))||(!strcmp(d->Value(),"description"))) { const TiXmlElement *g = (const TiXmlElement*)d; std::string mesh2 = g->GetText(); cout<< mesh2 <<endl; } } } } } } delete doc; getchar(); return 0; } 不能解析的文件是: <?xml version=1.0 encoding=ISO-8859-1 ?> <rss version=2.0 xmlns:dc=http://purl.org/dc/elements/1.1/> <channel> <title>Weather at Chicago / Waukegan, Waukegan Regional Airport, IL - via NOAA's National Weather Service</title> <link>http://www.weather.gov/data/current_obs/</link> <lastBuildDate>Sat, 28 Jul 2007 16:32:11 UT</lastBuildDate> <ttl>60</ttl> <description>Weather conditions from NOAA's National Weather Service.</description> <language>en-us</language> <managingEditor>robert.bunge@noaa.gov</managingEditor> <webMaster>w-nws.webmaster@noaa.gov</webMaster> <image> <url>http://www.weather.gov/images/xml_logo.gif</url> <title>NOAA - National Weather Service</title> <link>http://www.weather.gov/data/current_obs/</link> </image> <item> <title>Overcast and 73 degrees F at Chicago / Waukegan, Waukegan Regional Airport, IL</title> <link>http://weather.noaa.gov/weather/current/KUGN.html</link> <description> <![CDATA[ <img src=http://weather.gov/weather/images/fcicons/ovc.jpg class=noaaWeatherIcon width=55 height=58 alt=Overcast style=float:left; /><br /> ))> Winds are Northeast at 13 Gusting to 21 MPH. The pressure is 29.98 (1014.1 mb) and the humidity is 81%. The heat index is 73. Last Updated on Jul 28, 10:52 am CDT. </description> <guid isPermaLink=false>Sat, 28 Jul 2007 10:52:00 -0500 CDT</guid> </item> </channel> </rss> 但是将上面这个文件删减掉一些内容文件变小之后就可以解析了。 哪位达人帮帮忙呀!谢谢!
|