findNextParsed method
These methods use nextParsed
to iterate over the tags, comments,
strings, etc. that came after it in the document.
The findNextParsedAll method returns all matches, and findNextParsed only returns the first match.
Filters:
- pattern
, to search only for occurrences that satisfy
the RegExp match.
- nodeType
, what type of node/element to search.
- Node.ATTRIBUTE_NODE = 2;
- Node.CDATA_SECTION_NODE = 4;
- Node.COMMENT_NODE = 8;
- Node.DOCUMENT_FRAGMENT_NODE = 11;
- Node.DOCUMENT_NODE = 9;
- Node.DOCUMENT_TYPE_NODE = 10;
- Node.ELEMENT_NODE = 1;
- Node.ENTITY_NODE = 6;
- Node.ENTITY_REFERENCE_NODE = 5;
- Node.NOTATION_NODE = 12;
- Node.PROCESSING_INSTRUCTION_NODE = 7;
- Node.TEXT_NODE = 3;
// find all url links within the text node
final nextParsed = bs.findNextParsed(
pattern: RegExp(r'.*(.com)'),
nodeType: Node.TEXT_NODE,
);
Implementation
@override
Node? findNextParsed({
RegExp? pattern,
int? nodeType,
}) {
final filtered = findNextParsedAll(pattern: pattern, nodeType: nodeType);
return filtered.firstOrNull;
}