Export (0) Print
Expand All
DOM
Expand Minimize

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.

objXMLDOMSchemaCollection = objIXMLDOMDocument2.namespaces;

Example

NoteNote

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);
	}
}


Set objXMLDOMSchemaCollection = objIXMLDOMDocument2.namespaces

HRESULT get_namespaces (IXMLDOMSchemaCollection ** namespaceCollection);

Parameters

namespaceCollection[out, retval]

Collection of all namespaces for the document.

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

Implemented in: MSXML 3.0, MSXML 6.0

Show:
© 2014 Microsoft