Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Reference

startElement Method

Receives notification of the beginning of an element. The reader invokes the startElement method at the beginning of every element in the XML document.

[Visual Basic]

A corresponding endElement method is called for every startElement method, even when the element is empty.

Implementation Syntax

Sub startElement(strNamespaceURI As String, strLocalName As String,_ 
strQName As String, oAttributes As IVBSAXAttributes)

Usage Syntax

oContentHandler.startElement "xsl", "stylesheet", "xsl:stylesheet", _
oAttributes

Parameters

strNamespaceURI
The namespace URI.
strLocalName
The local name string.
strQName
The XML 1.0 qualified name (QName), with prefix, or an empty string (if QNames are not available).
oAttributes
The attributes collection attached to the element.

Return Values

If failed, the ContentHandler raises a trappable error.

Example

The following example uses the startElement method to set the text property for a text box (Text1) on the main application form (Form1). The new text indicates that the reader has begun reading the current element.

Private Sub IVBSAXContentHandler_startElement(strNamespaceURI As _
String, strLocalName As String, strQName As String, _
oAttributes As IVBSAXAttributes)
    Form1.Text1.Text = Form1.Text1.Text & "Start of element: " & _
                       strQName & vbCrLf
End Sub

Remarks

This method allows up to three names for each element:

Any or all of these name components may be specified, depending on the values of the "http://xml.org/sax/features/namespaces" and the "http://xml.org/sax/features/namespace-prefixes" features. The namespace URI and local name are required when the "http://xml.org/sax/features/namespaces" feature is set to True (the default). These values are optional when this feature is set to False.

Note   Neither the URI nor local name value can be specified on its own. Both values are required if either is used.

The QName is required when the "http://xml.org/sax/features/namespaces-prefixes feature" is set to True and is optional when this feature is set to False (the default).

The attribute list provided contains only attributes with explicit values (specified or default). The attribute list omits #IMPLIED attributes. Furthermore, the attribute list contains attributes used for namespace declarations (xmlns* attributes) only if the "http://xml.org/sax/features/namespace-prefixes" feature is set to True. This feature is set to False by default.

[C/C++]

A corresponding endElement method is called for every startElement event, even when the element is empty.

The startElement event allows up to three name components for each element:

Any or all of these name components may be specified, depending on the values of the "http://xml.org/sax/features/namespaces" and the "http://xml.org/sax/features/namespace-prefixes" features. The namespace URI and local name are required when the "http://xml.org/sax/features/namespaces" feature is set to True (the default). These values are optional when this feature is set to False.

Note   Neither the URI nor local name value can be specified alone. Both values are required if either is used.

The QName is required when the "http://xml.org/sax/features/namespaces-prefixes feature" is set to True and is optional when this feature is set to False (the default).

The attribute list provided contains only attributes with explicit values (specified or default). The attribute list omits #IMPLIED attributes. Furthermore, the attribute list contains attributes used for namespace declarations (xmlns* attributes) only if the "http://xml.org/sax/features/namespace-prefixes" feature is set to True. This feature is set to False by default.

Syntax

HRESULT startElement(
   [in] const wchar_t * pwchNamespaceUri, 
   [in] int cchNamespaceUri, 
   [in] const wchar_t * pwchLocalName, 
   [in] int cchLocalName
   [in] const wchar_t * pwchQName
   [in] int cchQName);
   [in] ISAXAttributes * pAttributes);

Parameters

pwchNamespaceUri [in]
The namespace URI.
cchNamespaceUri [in]
The length of the namespace URI.
pwchLocalName [in]
The local name string.
cchLocalName [in]
The length of the local name.
pwchQName [in]
The QName, with prefix, or, an empty string (if QNames are not available).
cchQName [in]
The length of the QName.
pAttributes [in]
The attributes attached to the element.

Return Values

S_OK
The value returned if no errors occur.
E_FAIL
The value returned if the parse operation should be aborted.

To view reference information for Visual Basic or C/C++ only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

endElement Method

Applies to: ISAXContentHandler/IVBSAXContentHandler Interface