using System.Collections.Generic;
using System.Xml.Serialization;
public static void Main()
@"<SearchSuggestion xmlns=""http://opensearch.org/searchsuggest2"" version=""2.0"">
<Query xml:space=""preserve"">middle ages</Query>
<Text xml:space=""preserve"">Middle Ages</Text>
<Url xml:space=""preserve"">https://en.wikipedia.org/wiki/Middle_Ages</Url>
<Description xml:space=""preserve"">In the history of Europe, the Middle Ages or medieval period lasted from the 5th to the 15th century. It began with the fall of the Western Roman Empire and merged into the Renaissance and the Age of Discovery.</Description>
<Image source=""https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/JuengeresMathildenkreuz.jpg/35px-JuengeresMathildenkreuz.jpg"" width=""35"" height=""50"" />
<Text xml:space=""preserve"">Middle Ages in film</Text>
<Url xml:space=""preserve"">https://en.wikipedia.org/wiki/Middle_Ages_in_film</Url>
<Description xml:space=""preserve"">Medieval films imagine and portray the Middle Ages through the visual, audio and thematic forms of cinema.</Description>
<Image source=""https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Fairbanks_Robin_Hood_standing_by_wall_w_sword.jpg/40px-Fairbanks_Robin_Hood_standing_by_wall_w_sword.jpg"" width=""40"" height=""50"" />
<Text xml:space=""preserve"">Talk:Middle Ages/GA1</Text>
<Url xml:space=""preserve"">https://en.wikipedia.org/wiki/Talk:Middle_Ages/GA1</Url>
<Text xml:space=""preserve"">Talk:Middle Ages/Archive 4</Text>
<Url xml:space=""preserve"">https://en.wikipedia.org/wiki/Talk:Middle_Ages/Archive_4</Url>
var serializer = new XmlSerializer(typeof(SearchItem));
var searchItem = (SearchItem)serializer.Deserialize(new StringReader(xml));
var third = searchItem.section.items[2];
const string nullText = "(null)";
Console.WriteLine($"Text: {third.Text}");
Console.WriteLine($"Url: {third.Url}");
Console.WriteLine($"Description: {third.Description ?? nullText}");
Console.WriteLine($"Image: {third.Image?.source ?? nullText}");
[XmlRoot("SearchSuggestion", Namespace = "http://opensearch.org/searchsuggest2")]
public string query { get; set; }
public Section section { get; set; }
public Item[] items { get; set; }
public string Text { get; set; }
public string Url { get; set; }
[XmlElement("Description")]
public string Description { get; set; }
public Image Image { get; set; }
public string source { get; set; }