title: Getting the value from an XML element via XSLT using value-of
body: <p>I know I'm missing something simple here, yet I can't figure it out.  I have other, more complex, XML and XSLT that are working but for some reason I can't get this specific one going.  I believe it's the structure of the XML file that's being generated during serialization.</p>
  
  <p>What I'm looking to do is get the value of an XML element and display it in HTML.  I've taken everything else away except the specific areas related to this issue.</p>
  
  <p>In the "html" variable in the code, the value for location is always blank.</p>
  
  <p>XML</p>
  
  <pre><code>&lt;WidgetBuilder&gt;
    &lt;DefaultLocation&gt;1234&lt;/DefaultLocation&gt;
  &lt;/WidgetBuilder&gt;
  </code></pre>
  
  <p>XSLT</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" exclude-result-prefixes="msxsl"&gt;
    &lt;xsl:output method="html" indent="yes" /&gt;
  
    &lt;xsl:template match="/"&gt;
      LOCATION: '&lt;xsl:value-of select="DefaultLocation" /&gt;'
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>string xml = File.ReadAllText(@"..\..\InitXml1.xml");
  string xslt = File.ReadAllText(@"..\..\InitXslt1.xslt");
  
  XPathDocument doc = new XPathDocument(new StringReader(xml));
  XslCompiledTransform xslTransform = new XslCompiledTransform();
  xslTransform.Load(XmlReader.Create(new StringReader(xslt)));
  
  StringWriter sw = new StringWriter();
  xslTransform.Transform(doc, null, sw);
  
  string html = sw.ToString();
  Console.WriteLine(html);
  </code></pre>