Skip to content

devlooped/Mvp.Xml

Repository files navigation

Icon

Version Downloads License Build

The original Mvp.Xml project, developed by Microsoft MVP's in XML technologies and XML Web Services worldwide. It is aimed at supplementing .NET XML processing. All the project's classes contain extensive tests to ensure its quality, as well as the peer review among this highly focused group of XML lovers.

Mvp.Xml project currently provides .NET implementations of EXSLT, XML Base, XInclude, XPointer as well as a unique set of utility classes and tools making XML programming in .NET platform easier, more productive and effective.

EXSLT

Example usage of EXSLT:

var xslt = new MvpXslTransform();
xslt.Load("foo.xsl");
// Optionally enforce the output to be XHTML
xslt.EnforceXHTMLOutput = true;
xslt.Transform(new XmlInput("foo.xml"), new XmlOutput("result.html"));

Usage in XPath-only context:

XPathExpression expr = nav.Compile("set:distinct(//author)");
expr.SetContext(new ExsltContext(doc.NameTable));
XPathNodeIterator authors = nav.Select(expr);
while (authors.MoveNext())
    Console.WriteLine(authors.Current.Value);

XInclude

Example usage of XInclude:

var reader = new XIncludingReader(XmlReader.Create(uri));
var document = XDocument.Load(reader);

Miscelaneous

Some other helper classes include:

public XPathNodeIterator GetExpensiveBooks(IXPathNavigable doc, int minPrice)
{
 string expr = "//mvp:titles[mvp:price > $price]";
 
 // XPathCache optimally caches the compiled XPath expression and parameterizes it
 return XPathCache.Select(expr, doc.CreateNavigator(), mgr, new XPathVariable("price", minPrice));
}
var xslt = new XslTransform();
xslt.Load("print_root.xsl");
var doc = new XPathDocument("library.xml");
 
var books = doc.CreateNavigator().Select("/library/book");
while (books.MoveNext())
{
    // Transform subtree for current node
    xslt.Transform(new SubtreeeXPathNavigator(books.Current), null, Console.Out, null);
}

Sponsors

Clarius Org Kirill Osenkov MFB Technologies, Inc. Stephen Shaw Torutek DRIVE.NET, Inc. Daniel Gnägi Ashley Medway Keith Pickford Thomas Bolon Kori Francis Sean Killeen Toni Wenzel Giorgi Dalakishvili Mike James Dan Siegel Reuben Swartz Jacob Foshee Eric Johnson Norman Mackay Certify The Web Ix Technologies B.V. David JENNI Jonathan Oleg Kyrylchuk Charley Wu Jakob Tikjøb Andersen Seann Alexander Tino Hager Mark Seemann Angelo Belchior Ken Bonny Simon Cropp agileworks-eu sorahex Zheyu Shen Vezel

Sponsor this project  

Learn more about GitHub Sponsors