代码之家  ›  专栏  ›  技术社区  ›  bear

将twitter xml导入visual basic

  •  0
  • bear  · 技术社区  · 15 年前

    我试图将twitter提供的xml导入visual basic中的可读格式。

    XML看起来像:

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <statuses type="array">
      - <status>
         <created_at>Mon Jan 18 20:41:19 +0000 2010</created_at> 
         <id>111111111</id> 
         <text>thattext</text> 
         <source><a href="http://www.seesmic.com/" rel="nofollow">Seesmic</a></source> 
         <truncated>false</truncated> 
         <in_reply_to_status_id>7916479948</in_reply_to_status_id> 
         <in_reply_to_user_id>90978206</in_reply_to_user_id> 
         <favorited>false</favorited> 
         <in_reply_to_screen_name>radonsystems</in_reply_to_screen_name> 
          - <user>
             <id>20193170</id> 
             <name>personname</name> 
             <screen_name>screenname</screen_name> 
             <location>loc</location> 
             <description>desc</description> 
       <profile_image_url>http://a3.twimg.com/profile_images/747012343/twitter_normal.png</profile_image_url> 
             <url>myurl</url> 
             <protected>false</protected> 
             <followers_count>97</followers_count> 
             <profile_background_color>ffffff</profile_background_color> 
             <profile_text_color>333333</profile_text_color> 
             <profile_link_color>0084B4</profile_link_color> 
             <profile_sidebar_fill_color>ffffff</profile_sidebar_fill_color> 
             <profile_sidebar_border_color>ababab</profile_sidebar_border_color> 
             <friends_count>76</friends_count> 
             <created_at>Thu Feb 05 21:54:24 +0000 2009</created_at> 
             <favourites_count>1</favourites_count> 
             <utc_offset>0</utc_offset> 
             <time_zone>London</time_zone> 
             <profile_background_image_url>http://a3.twimg.com/profile_background_images/76723999/754686.png</profile_background_image_url> 
             <profile_background_tile>true</profile_background_tile> 
             <notifications>false</notifications> 
             <geo_enabled>true</geo_enabled> 
             <verified>false</verified> 
             <following>false</following> 
          <statuses_count>782</statuses_count> 
          <lang>en</lang> 
          <contributors_enabled>false</contributors_enabled> 
       </user>
      <geo /> 
      <coordinates /> 
      <place /> 
      <contributors /> 
      </status>
      </statuses>
    

    现在,我想将它显示在一个面板中,该面板在特定时间段后自动刷新,但是,我只想从该xml中提取特定的信息位,例如 profile_image_url text created_at . 您可以猜测数据的格式,就像tweetdeck和其他twitter客户机中显示的格式一样。

    我对visual basic还不太熟悉,那我该怎么做呢?

    谢谢

    2 回复  |  直到 13 年前
        1
  •  2
  •   davidb    15 年前

    您将需要解析xml,查找相关的标记(例如created),然后检索它们的数据。我最近在c_中使用xmlreader类完成了这项工作,效果很好。

    以下是指向Visual Basic文档的链接: http://msdn.microsoft.com/en-us/library/cc189056(VS.95).aspx

    在链接中可以看到,只需打开节点类型并执行相关操作。这是一种快速解析XML的方法,因为它不会将整个文档加载到内存中。

        2
  •  0
  •   bmargulies    15 年前

    使用msxml com对象解析xml,然后提取所需的位。