Share via


MoveToFirstAttribute (Compact 7)

3/12/2014

This interface moves the reader position to the first attribute within the current node.

Syntax

HRESULT MoveToFirstAttribute ();

Return Value

This interface returns S_OK if no error is generated. If there are no attributes on the current node, this interface returns S_FALSE and does not move the position of the reader.

Remarks

This method is frequently used to return to the beginning of the attribute list.

After this method is called, the attributes collection on the element is still available. The application can then call other methods that move the reader within the attributes collection.

The following code moves to the first attribute of an element by calling MoveToFirstAttribute:

HRESULT WriteAttributes(IXmlReader* pReader)
{
    const WCHAR* pwszPrefix;
    const WCHAR* pwszLocalName;
    const WCHAR* pwszValue;
    HRESULT hr = pReader->MoveToFirstAttribute();

    if (S_FALSE == hr)
        return hr;
    if (S_OK != hr)
    {
        wprintf(L"Error moving to first attribute, error is %08.8lx", hr);
        return -1;
    }

See Also

Reference

IXmlReader Methods
MoveToNextAttribute
MoveToAttributeByName
IXmlReader Properties
Error Codes