Archive for December, 2008

C# Code parse youtube data feed example

http://latebound.blogspot.com/2008/01/youtube-api-parser-in-one-line-of-code.html

1 Comment

Silverlight 2.0 Image Binding error: AG_E_NETWORK_ERROR

I start building my first app follow the example from ScottGu, retrieving youtube data feed.

One problem I found is when I using Image Binding to get video thumnails, there is a Error:Sys.InvalidOperationException: ImageError error #4001 in control ‘Xaml1’: AG_E_NETWORK_ERROR

Here is Scott ‘s code:

————————————————————-
var stories = from story in xmlStories.Descendants("story")
where story.Element("thumbnail") != null &&
!story.Element("thumbnail").Attribute("src").Value.EndsWith(".gif")
select new DiggStory
{
Id = (int)story.Attribute("id"),
Title = ((string)story.Element("title")).Trim(),
Description = ((string)story.Element("description")).Trim(),
ThumbNail = (string)story.Element("thumbnail").Attribute("src").Value,
HrefLink = new Uri((string)story.Attribute("link")),
NumDiggs = (int)story.Attribute("diggs"),
UserName = (string)story.Element("user").Attribute("name").Value,
};

-------------------------------------------------------------

The line: HrefLink = new Uri((string)story.Attribute("link")) is not working for me.

After checking the code, I found Image.Source property is expecting ImageSource Oject , not really uri object.  HrefLink should be defined as ImageSource Object, and the line should be:

HrefLink = new BitmapImage(new Uri((string)story.Attribute(“link”)))

 Then it works fine for me.

1 Comment

script.aculo.us – userful Javascript library

http://script.aculo.us/

Nice page effect.

Leave a comment

40+ Tooltips Scripts With AJAX, JavaScript & CSS

Some nice JS&CSS tooltips

http://www.smashingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-css-dhtml/

Leave a comment

Removing default namespaces from an XDocument

http://www.moggoly.me.uk/blog/post/Removing-default-namespaces-from-an-XDocument.aspx

This post gives a handy function to remove default namespace in Xdocument.

My problem was  Xdocument.Descendants(ElementName) failed to get result, and there are Namespaces in root element. 

 

   1: private XDocument RemoveNamespace(XDocument xdoc)
   2: {
   3:     foreach (XElement e in xdoc.Root.DescendantsAndSelf())
   4:     {
   5:         if (e.Name.Namespace != XNamespace.None)
   6:         {
   7:             e.Name = XNamespace.None.GetName(e.Name.LocalName);
   8:         }
   9:         if (e.Attributes().Where(a => a.IsNamespaceDeclaration || a.Name.Namespace != XNamespace.None).Any())
  10:         {
  11:             e.ReplaceAttributes(e.Attributes().Select(a => a.IsNamespaceDeclaration ? null : a.Name.Namespace != XNamespace.None ? new XAttribute(XNamespace.None.GetName(a.Name.LocalName), a.Value) : a));
  12:         }
  13:     }
  14: 
  15:     return xdoc;
  16: }

10 Comments

A simple comparison between Adobe AIR and MS Silverlight

http://kokchiann.wordpress.com/2007/07/19/air-and-wpf/

Leave a comment