Freigeben über


namespaces Property

 

Returns the list of namespaces used in the document as XMLSchemaCache.

In MSXML 6.0, this property returns just the namespaces that were used in the process of validation, not all of the namespaces that were added to the schema cache.

Script Syntax

objXMLDOMSchemaCollection = objIXMLDOMDocument2.namespaces;  

Example

Note

You can use the files (Books.xml, Books.xsd) in Resource Files (books.xml and books.xsd) to run this example code.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmlDoc.async = false;
// Load a document (and any schemas referenced via X-Schema).
xmlDoc.resolveExternals = true;
xmlDoc.load ("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
    var myErr = xmlDoc.parseError;
    WScript.Echo("You have error " + myErr.reason);
} else {
    // Get the namespace of the root element.
    var namespaceURI = xmlDoc.documentElement.namespaceURI;
    // Find the schema associated with the namespace.
    var schema = xmlDoc.namespaces.get(namespaceURI);
    if (schema != null)
    {
        WScript.Echo("got namespaces");
        WScript.Echo(schema.xml);
    }
}

Visual Basic Syntax

Set objXMLDOMSchemaCollection = objIXMLDOMDocument2.namespaces  

C/C++ Syntax

HRESULT get_namespaces (IXMLDOMSchemaCollection ** namespaceCollection);  

Parameters

namespaceCollection [out, retval]
Collection of all namespaces for the document.

Remarks

If there are no schemas, it returns an empty collection.

Versioning

Implemented in: MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMDocument-DOMDocument