tags:

views:

34

answers:

2

Hello, 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&lt;/profile_image_url&gt; 
         <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&lt;/profile_background_image_url&gt; 
         <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 presented in TweetDeck and other Twitter clients.

I'm quite new to Visual Basic, so how could I do this?

Thanks

A: 

Use the MSXML com object to parse the xml and then pull out the bits you need.

bmargulies
+2  A: 

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.

davidb
Hi, whilst that sort of works, what is the equivalent of OutputTextBlock since that exists in Silverlight, and not visual basic as a an output?
Shamil
From your initial question it seems like you want to store the information so that it can be displayed in a GUI?In this case, you would probably want to put it into an aptly named String variable.Of course, you could use a simple print statement to send the output to the console if you just want to debug
davidb
Yep, that is correct, it is to be displayed in a GUI.
Shamil
Use reader.Value to access the text contained within the element, you can then store this and use it however you need to
davidb
Thank you very much!
Shamil