From 556f1650b14a8c8f0dcce60589731480741e805f Mon Sep 17 00:00:00 2001
From: "Fred L. Drake, Jr."
XML_SetUserData
function) to pass a
-pointer to this structure to the handlers. This is typically the first
-argument received by most handlers.
+pointer to this structure to the handlers. This is the first
+argument received by most handlers. In the reference section, an argument to a callback function is named
+userData
and have type void *
if the user
+data is passed; it will have the type XML_Parser
if the
+parser itself is passed. When the parser is passed, the user data may
+be retrieved using XML_GetUserData
.
+
+One common case where multiple calls to a single handler may need
+to communicate using an application data structure is the case when
+content passed to the character data handler (set by XML_SetCharacterDataHandler
) needs to be accumulated. A
+common first-time mistake with any of the event-oriented interfaces to
+an XML parser is to expect all the text contained in an element to be
+reported by a single call to the character data handler. Expat, like
+many other XML parsers, reports such data as a sequence of calls;
+there's no way to know when the end of the sequence is reached until a
+different callback is made. A buffer referenced by the user data
+structure proves both an effective and convenient place to accumulate
+character data.