新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> XML编辑器,XML解析器,XML开发环境
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XML工具及XML开发环境 』 → tinyxml不能解析大文件? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 6640 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: tinyxml不能解析大文件? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     skyyks 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:6
      积分:69
      门派:XML.ORG.CN
      注册:2008/8/20

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给skyyks发送一个短消息 把skyyks加入好友 查看skyyks的个人资料 搜索skyyks在『 XML工具及XML开发环境 』的所有贴子 引用回复这个贴子 回复这个贴子 查看skyyks的博客楼主
    发贴心情 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>
    但是将上面这个文件删减掉一些内容文件变小之后就可以解析了。
    哪位达人帮帮忙呀!谢谢!


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/12/22 16:21:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML工具及XML开发环境 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/27 19:54:36

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    54.688ms