MSXML (Microsoft XML Core Services) is a COM component in Windows with DOM, SAX, XPath, XSLT 1.0 and XSD. MSXML 6.0 is the version to use, its documentation now sits in Microsoft's archived "previous versions" library, and new Windows code uses .NET's System.Xml. Both are on every Windows 11 machine; this script ran in PowerShell 55,538 on the Windows host:
# Windows only: MSXML 6 through COM, then .NET's XmlReader
$path = (Resolve-Path ..\booknest-catalog.xml).Path
$dom = New-Object -ComObject MSXML2.DOMDocument.6.0
$dom.async = $false; $null = $dom.load($path)
"MSXML 6: {0} books, first: {1}" -f $dom.selectNodes("//book").length,
$dom.selectSingleNode("//book[1]/title").text
$reader = [System.Xml.XmlReader]::Create($path)
$total = [decimal]0
while ($reader.ReadToFollowing("price")) {
$total += [decimal]$reader.ReadElementContentAsString()
}
$reader.Close()
".NET {0} XmlReader: total {1}" -f [Environment]::Version, $totalOutput
MSXML 6: 6 books, first: The Quiet Harbor .NET 4.0.30319.42000 XmlReader: total 134.74
Keep MSXML for maintaining classic ASP, VBA and VBScript code, not for new pipelines.
MSXML
Microsoft XML Core Services (MSXML) is a collection of services that allow JScript applications, VBScript applications, and Microsoft development tools to create XML applications on Windows. DOM, SAX, XSLT, XSD, and more are supported.MSXML ships as a COM component bundled with Windows and is accessed through ProgIDs such as MSXML2.DOMDocument.6.0, the current, recommended version; earlier versions such as MSXML 3.0 and 4.0 are legacy and no longer recommended for new development. Because it is COM-based, MSXML can be used from VBScript, JScript, VBA, classic ASP, and C++ (via COM), in addition to Microsoft's own development tools. It provides a DOM implementation, SAX2-compatible interfaces (IVBSAXXMLReader / ISAXXMLReader), an XSLT processor, and DTD/XSD-based validation.
| Full name | Microsoft XML Core Services |
| Distribution | COM component bundled with Windows |
| Accessible from | VBScript, JScript, VBA, classic ASP, C++ (COM) |
| Current version | MSXML 6.0 (ProgID MSXML2.DOMDocument.6.0); earlier versions (3.0, 4.0) are legacy |
| Supports | DOM, SAX, XSLT, XSD validation |
var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.6.0");
xmlDoc.async = false;
xmlDoc.load("books.xml");
var books = xmlDoc.getElementsByTagName("book");
for (var i = 0; i < books.length; i++) {
WScript.Echo("Book id: " + books[i].getAttribute("id"));
}