Title: startElement
Published: April 25, 2014
Last modified: August 20, 2026

---

# startElement( resource $parser, string $tag_name, array $attrs )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Starts a new XML tag.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#description)󠁿

Callback function for xml_set_element_handler().

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#parameters)󠁿

 `$parser`resourcerequired

XML Parser resource.

`$tag_name`stringrequired

XML element name.

`$attrs`arrayrequired

XML element attributes.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#source)󠁿

    ```php
    function startElement( $parser, $tag_name, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    	global $names, $urls, $targets, $descriptions, $feeds;

    	if ( 'OUTLINE' === $tag_name ) {
    		$name = '';
    		if ( isset( $attrs['TEXT'] ) ) {
    			$name = $attrs['TEXT'];
    		}
    		if ( isset( $attrs['TITLE'] ) ) {
    			$name = $attrs['TITLE'];
    		}
    		$url = '';
    		if ( isset( $attrs['URL'] ) ) {
    			$url = $attrs['URL'];
    		}
    		if ( isset( $attrs['HTMLURL'] ) ) {
    			$url = $attrs['HTMLURL'];
    		}

    		// Save the data away.
    		$names[]        = $name;
    		$urls[]         = $url;
    		$targets[]      = $attrs['TARGET'] ?? '';
    		$feeds[]        = $attrs['XMLURL'] ?? '';
    		$descriptions[] = $attrs['DESCRIPTION'] ?? '';
    	} // End if outline.
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/link-parse-opml.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/link-parse-opml.php#L37)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/link-parse-opml.php#L37-L63)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/startElement/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fstartelement%2F)
before being able to contribute a note or feedback.