XMLScanner object

XMLScanner - XML/HTML tokenzier. Also known as XML push parser.

Constants

return values of token() method

ERROR
- error in markup of input stream
EOF
- end of stream reached
HEAD
- head of the element parsed:
<tag ...
 ^-- happens here
HEAD_END
- end of head of non-empty element parsed:
<tag ... >
      ^-- happens here
EMPTY_HEAD_END
- end of head of empty element parsed:
<tag ... />
       ^-- happens here
TAIL
- tail of the non-empty element parsed:
</tag>
^-- happens here
ATTR
- attribute parsed:
<tag attr="value" >
                ^-- happens here

Attribute can be with or without (html style) value. scanner.attribute is the name of attribute and scanner.value - is a value of attribute.

TEXT
- text parsed.

scanner.value contains the text.

CDATA
- cdata parsed:
<![CDATA[ ...value... ]]>
                    ^-- happens here

scanner.value contains text of the cdata.

PI
- processing instruction parsed:
<? ...value... ?>
             ^-- happens here

scanner.value contains text of the instruction.

DOCTYPE
- doctype declaration parsed:
<!DOCTYPE ...value... >
                     ^-- happens here

scanner.value contains text of the doctype declaration: characters after <!DOCTYPE and before closing '>'

Properties

value
- string, text of attribute value, text, cdata or pi.
attribute
- string, name of the attribute. Valid if token == XMLScanner.ATTR
tag
- string, name of the tag. Valid if token is XMLScanner.HEAD, XMLScanner.TAIL or XMLScanner.HEAD_END.

Methods

token

(  ) returns: int

Returns one of constants above. Use them in fully qualified form, e.g. XMLScanner.HEAD, XMLScanner.TAIL, etc.