Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

The xml_get_current_column_number function returns the column number in
the source file where the parser last read data. This function is useful for reporting where
an error occurred.


integer xml_get_current_line_number(integer parser)


The xml_get_current_line_number function returns the line number in the
source file where the parser last read data. This function is useful for reporting where an
error occurred.


integer xml_get_error_code(integer parser)


The xml_get_error_code function returns the last error code generated on the given


parser. Constants are defined for all the errors. They are listed in Table 14.13. If no
error has occurred, XML_ERROR_NONE is returned. If given an invalid parser identifier,
FALSE is returned.


boolean xml_parse(int parser, string data, boolean final)


The xml_parse function scans over data and calls handlers you have registered. The
size of the data argument is not limited. You could parse an entire file or a few bytes at
a time. A typical use involves fetching data within a while loop.


The final argument is optional. It tells the parser that the data you are passing is the
end of the file.


boolean xml_parse_into_struct(int parser, string data, array
structure, array index)


The xml_parse_info_struct function parses an entire document and creates an
array to describe it. You must pass the structure argument as a reference. Elements
numbered from zero will be added to it. Each element will contain an associative array
indexed by tag, type, level, and value. The index argument is optional. You
must pass it by reference as well. It will contain elements indexed by distinct tags found
in the XML file. The value of each element will be a list of integers. These integers are
indices into the structure array. It allows you to index the elements of the
structure array that match a given tag.


If you set any handlers, they will be called when you use xml_parse_into_struct.


Figure 14-4. xml_parse_into_struct.
Free download pdf