ElementParser.onStartTag

Register a handler which will be called whenever a start tag is encountered which matches the specified name. You can also pass null as the name, in which case the handler will be called for any unmatched start tag.

class ElementParser
ParserHandler[string] onStartTag;

Examples

1 // Call this function whenever a <podcast> start tag is encountered
2 onStartTag["podcast"] = (ElementParser xml)
3 {
4     // Your code here
5     //
6     // This is a a closure, so code here may reference
7     // variables which are outside of this scope
8 };
9 
10 // call myEpisodeStartHandler (defined elsewhere) whenever an <episode>
11 // start tag is encountered
12 onStartTag["episode"] = &myEpisodeStartHandler;
13 
14 // call delegate dg for all other start tags
15 onStartTag[null] = dg;

This library will supply your function with a new instance of ElementHandler, which may be used to parse inside the element whose start tag was just found, or to identify the tag attributes of the element, etc.

Note that your function will be called for both start tags and empty tags. That is, we make no distinction between &lt;br&gt;&lt;/br&gt; and &lt;br/&gt;.

Meta

Suggestion Box / Bug Report