XmlWriter that can produce an XPathDocument without the need to parse XML.
Using this writer whenever you need to perform fast chained transformations. Using this class avoids reparsing of the intermediate output, yielding lower memory and CPU usage.

Future versions of XPathDocument may offer this functionality out of the box.

Important: this class requires unrestricted member access reflection permissions in order to run. If the Mvp.Xml assembly is installed in the GAC, it will run without problems. The Mvp.Xml allows partially trusted callers, so only this assembly needs to be GAC'ed.

Alternatively, you can configure .NET security policy to allow the appropriate permission (see ReflectionPermission, PermissionState.Unrestricted and ReflectionPermissionFlag.MemberAccess).

Inheritance: System.Xml.XmlWrappingWriter
		public void ShouldUseBaseUriForDocument()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter("kzu-uri");
			writer.WriteStartElement("Foo");
			XPathDocument doc = writer.Close();

			Assert.IsNotNull(doc);
			Assert.AreEqual("kzu-uri", doc.CreateNavigator().BaseURI);
		}
		public void ShouldWriteRootElement()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter();
			writer.WriteElementString("hello", "world");
			XPathDocument doc = writer.Close();

			Assert.IsNotNull(doc);

			string xml = GetXml(doc);

			Assert.AreEqual("<hello>world</hello>", xml);
		}
		public void WriterIsDisposable()
		{
			XPathDocument doc;
			using (XPathDocumentWriter writer = new XPathDocumentWriter())
			{
				writer.WriteElementString("hello", "world");
				doc = writer.Close();
			}

			Assert.IsNotNull(doc);
		}
		public void ShouldAcceptStartElementRootOnly()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter();
			writer.WriteStartElement("Foo");
			XPathDocument doc = writer.Close();
		}
		public void ShouldThrowIfNoRootWritten()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter();
			XPathDocument doc = writer.Close();
		}
		public void ShouldThrowWithNullBaseUri()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter((string)null);
		}
		public void ShouldAllowEmptyBaseUri()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter(String.Empty);
			Assert.IsNotNull(writer);
		}
		public void ShouldCreateXmlWriterForDocument()
		{
			XPathDocumentWriter writer = new XPathDocumentWriter();
			Assert.IsNotNull(writer);
		}