Returns the attribute with the specified namespace and attribute name.
var objXMLDOMNode = oXMLDOMNamedNodeMap.getQualifiedItem(baseName, namespaceURI);
An object. Returns the attribute node specified by the baseName and namespaceURI parameters. Returns Null if the attribute is not in the collection or if the item is not an attribute.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var oNamedNodeMap, nodeBook;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
var myErr = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
nodeBook = xmlDoc.selectSingleNode("//book");
oNamedNodeMap = nodeBook.attributes;
alert(oNamedNodeMap.getQualifiedItem("id", "").value);
}
Set objXMLDOMNode = oXMLDOMNamedNodeMap.getQualifiedItem(baseName, namespaceURI)
An object. Returns the attribute node specified by the baseName and namespaceURI parameters. Returns Null if the attribute is not in the collection or if the item is not an attribute.
Dim xmlDoc As New Msxml2.DOMDocument50
Dim oNamedNodeMap As IXMLDOMNamedNodeMap
Dim nodeBook As IXMLDOMElement
Dim nodeId As IXMLDOMAttribute
xmlDoc.async = False
xmlDoc.Load "books.xml"
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set nodeBook = xmlDoc.selectSingleNode("//book")
Set oNamedNodeMap = nodeBook.Attributes
Set nodeId = oNamedNodeMap.getQualifiedItem("id", "")
MsgBox nodeId.Value
End If
HRESULT getQualifiedItem(
BSTR baseName,
BSTR namespaceURI,
IXMLDOMNode **qualifiedItem);
baseName and namespaceURI parameters. Returns Null if the attribute is not in the collection or if the item is not an attribute.qualifiedItem is Null.IXMLDOMNode *pIXMLDOMNode = NULL;
IXMLDOMNamedNodeMap *pIXMLDOMNamedNodeMap = NULL;
BSTR bstrAttributeName = ::SysAllocString(_T("dateModified"));
IXMLDOMElement *pIXMLDOMElement = NULL;
VARIANT varValue;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
HRESULT hr;
try
{
// Create an instance of DOMDocument and initialize pIXMLDOMDocument.
// Load/create an XML fragment.
hr = pIXMLDOMDocument->get_documentElement(&pIXMLDOMElement);
SUCCEEDED(hr) ? 0 : throw hr;
if(pIXMLDOMElement)
{
hr = pIXMLDOMElement->get_attributes(&pIXMLDOMNamedNodeMap);
if(SUCCEEDED(hr) && pIXMLDOMNamedNodeMap)
{
hr = pIXMLDOMNamedNodeMap->getQualifiedItem(bstrAttributeName, NULL, &pIXMLDOMNode);
if(SUCCEEDED(hr) && pIXMLDOMNode)
{
pIXMLDOMNode->get_nodeValue(&varValue);
::MessageBox(NULL, _bstr_t(varValue), _T("Item Value"), MB_OK);
pIXMLDOMNode->Release();
pIXMLDOMNode = NULL;
}
pIXMLDOMNamedNodeMap->Release();
pIXMLDOMNamedNodeMap = NULL;
}
pIXMLDOMElement->Release();
pIXMLDOMElement = NULL;
}
::SysFreeString(bstrAttributeName);
bstrAttributeName = NULL;
}
catch(...)
{
if(bstrAttributeName)
::SysFreeString(bstrAttributeName);
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
if(pIXMLDOMNamedNodeMap)
pIXMLDOMNamedNodeMap->Release();
if(pIXMLDOMNode)
pIXMLDOMNode->Release();
DisplayErrorToUser();
}
// Release pIXMLDOMDocument when finished with it.
This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
Applies to: IXMLDOMNamedNodeMap