' ); + * $processor->next_tag( 'img' ); + * $processor->get_breadcrumbs() === array( 'p', 'strong', 'em', 'img' ); + * + * @since WP_VERSION + * + * @return string[]|null Array of tag names representing path to matched node, if matched, otherwise NULL. + */ + public function get_breadcrumbs() { + return $this->stack_of_open_elements; + } + + /** + * Indicates if the currently-matched tag matches the given breadcrumbs. + * + * A "*" represents a single tag wildcard, where any tag matches, but not no tags. + * + * At some point this function _may_ support a `**` syntax for matching any number + * of unspecified tags in the breadcrumb stack. This has been intentionally left + * out, however, to keep this function simple and to avoid introducing backtracking, + * which could open up surprising performance breakdowns. + * + * Example: + * + * $processor = new WP_XML_Tag_Processor( '
Previous XMLMore XML
+ * ↑ │ back up by the length of the tag name plus the opening < + * └←─┘ back up by strlen("em") + 1 ==> 3 + */ + $this->bytes_already_parsed = $before_current_tag; + $this->base_class_next_token(); + + return $this->xml; + } + + /** + * Parses tag query input into internal search criteria. + * + * @since WP_VERSION + * + * @param array|string|null $query { + * Optional. Which tag name to find, having which class, etc. Default is to find any tag. + * + * @type string|null $tag_name Which tag to find, or `null` for "any tag." + * @type int|null $match_offset Find the Nth tag matching all search criteria. + * 1 for "first" tag, 3 for "third," etc. + * Defaults to first tag. + * @type string $tag_closers "visit" or "skip": whether to stop on tag closers, e.g.snow-capped
' ); + + $subclass->next_tag(); + $this->assertSame( + 'p', + $subclass->get_tag(), + 'Should have matched inserted XML as next tag.' + ); + + $subclass->next_tag( 'photo' ); + $subclass->set_attribute( 'alt', 'mountain' ); + + $this->assertSame( + 'snow-capped
Two roads diverged in a yellow wood,
And sorry I could not travel both
+One seemed great, but the other seemed great too. +There was also a third option, but it was not as great. + +playground.wordpress.net/new-path/one was the best choice. +https://playground.internal/path-not-taken was the second best choice. +
+]]>Two roads diverged in a yellow wood,
And sorry I could not travel both
+One seemed great, but the other seemed great too. +There was also a third option, but it was not as great. + +playground.internal/path/one was the best choice. +https://playground.internal/path-not-taken was the second best choice. +
+]]>