I'm trying to import an XML that's provided by twitter into a readable format in Visual Basic.
XML looks like:
<?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>
Now, I want to display it in a panel that automatically refresh after a certain period, however, I only want to pick out certain bits of info from that xml, such as profile_image_url
and text
and created_at
. You can guess how the data will be formatted, much like that pr开发者_运维知识库esented in TweetDeck and other Twitter clients.
I'm quite new to Visual Basic, so how could I do this?
Thanks
You will need to parse the XML, looking for the relevant tags (such as created_at) and then retrieving their data. I did this recently in C# using the XmlReader class and it worked well.
Here is a link to the Visual Basic docs: http://msdn.microsoft.com/en-us/library/cc189056(VS.95).aspx
As you can see in the link, you just switch on the node type and perform the relevant action. This is a fast way to parse the Xml as it doesn't load the whole document into memory.
Use the MSXML com object to parse the xml and then pull out the bits you need.
精彩评论