Controlling Parser Behavior

Currently, PHP’s XML parser allows you to control the following:

  • Case folding

  • Target encoding

  • Whitespace processing

All these attributes can be controlled via the xml_set_option() function, which accepts three parameters:

  • A handle for the parser to be modified

  • The attribute name

  • The attribute value (either string or Boolean)

The sections that follow describe each of these parameters in greater detail with examples.

Case Folding

Within the context of an XML document, case folding simply involves replacing lowercase characters in element names with their uppercase equivalents. XML element names are case-sensitive; typically, you use case folding to impose consistency on mixed-case element names so that they can be handled ...

Get XML and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.