Partager via


endElement Method

 

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

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

Visual Basic Implementation Syntax

Sub endElement(strNamespaceURI As String, strLocalName As_  
String, strQName As String)  

Visual Basic Usage Syntax

oContentHandler.endElement "xsl", "stylesheet", "xsl:stylesheet"  

Parameters

strNamespaceURI
The namespace URI or an empty string (if the element has no namespace URI, or if namespaces are not being processed).

strLocalName
The local name, without prefix, or an empty string (if namespace processing is not being performed).

strQName
The XML 1.0 qualified name (QName), with prefix, or an empty string (if the QName is not available).

Return Values

If failed, the ContentHandler raises a trappable error.

Example

The following example uses the endElement 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 finished reading the current element.

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

C/C++ Syntax

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

Parameters

pwchNamespaceUri[in]
The namespace URI.

cchNamespaceUri[in]
The length of the namespace URI string.

pwchLocalName[in]
The local name string.

cchLocalName[in]
The length of the local name string.

pwchQName[in]
The QName, with prefix, or an empty string (if QNames are not available).

cchQName[in]
The length of the QName string.

Return Values

S_OK
The value returned if no errors occur.

E_FAIL
The value returned if the parse operation should be aborted.

Remarks

This method allows up to three names for each element:

  • The namespace URI.

  • The local name.

  • The QName, if available.

Which of these names are specified depends 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 True (the default). These values are optional when this feature is set to False.

Note

Neither the URI nor the 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).

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

This event allows up to three name components for each element:

  • The namespace URI.

  • The local name.

  • The qualified XML 1.0 name (QName), with prefix, or an empty string if the QName is not available.

Any or all of these name components may be provided, 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 the 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).

Versioning

Implemented in: MSXML 3.0 and later

See Also

startElement Method
ISAXContentHandler Interface