O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing to XML

Writing objects to XAML in XML form is a common activity. Because XamlObjectReader doesn’t support WPF-style objects, Listing 21.4 demonstrates converting from XML to XML by pairing up XamlXmlReader with XamlXmlWriter. This may sound nonsensical, but the combination produces a simple “XAML scrubber” that normalizes the input XML to produce consistently represented, consistently spaced XML with comments removed.

LISTING 21.4 A “XAML Scrubber” That Normalizes the Input XML

public static string RewriteXaml(string xmlString){  // String -> TextReader -> XamlXmlReader  using (TextReader textReader = new StringReader(xmlString))  using (XamlXmlReader reader = new XamlXmlReader(textReader))  // TextWriter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required