[Fork] <no name>

CSharp · Console

/Program.cs

using System;
using System.Xml;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
					
public class Program {
	public static void Main() {
		
		string stringXml = @"<user>
                                 <image size='small'>http://userserve-ak.last.fm/serve/34/101313093.jpg</image>
                                <image size='medium'>http://userserve-ak.last.fm/serve/64/101313093.jpg</image>
                                <image size='large'>http://userserve-ak.last.fm/serve/126/101313093.jpg</image>
                                <image size='extralarge'>http://userserve-ak.last.fm/serve/252/101313093.jpg</image>
                                </user>";
		
		XElement xdoc = XElement.Parse(stringXml);
		
		
		var result= xdoc.Descendants("image")
                .Where(x => x.Attribute("size").Value == "large")
                .Select(x => new User{ Image =  x.Value });
		
		foreach (var item in result) 
			Console.WriteLine(item.Image);
		
		
	}
	
	public class User {
	
		public string Image {get;set;}
		
	}
	
	
}
;