次の方法で共有


GetLocalName

 

Gets the local name of the node that the reader is currently positioned on. If no local name is available, this method returns an empty string.

Syntax

  
HRESULT GetLocalName ([out] const WCHAR ** ppwszLocalName, [out] UINT * pcwchLocalName);  

Arguments

ppwszLocalName
The local name of the node that the reader is currently positioned on. The returned string is always NULL terminated.

If no local name is available, the returned string is empty.

The passed in value cannot be NULL.

pcwchLocalName
The size of the string, in characters, is returned.

This value is optional. You can pass NULL for it, and the method will not return a value.

Return Value

Returns S_OK if no error is generated.

Remarks

If the reader is positioned on the element <p:abc/>, for example, this method returns the string "abc".

Note

The pointer returned by GetLocalName is only valid until you move the reader to another node. When you move the reader to another node, XmlLite may reuse the memory referenced by the pointer. Therefore, you should not use the pointer after calling one of the following methods: Read, MoveToNextAttribute, MoveToFirstAttribute, MoveToAttributeByName, or MoveToElement. Although they do not move the reader, the following two methods will also make the pointer invalid: SetInput and IUnknown::Release. If you want to preserve the value that was returned in ppwszLocalName, you should make a deep copy.

The following code gets the local name from a reader:

if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL)))  
{  
    wprintf(L"Error getting local name, error is %08.8lx", hr);  
    return -1;  
}  

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

GetQualifiedName