Darren Odom wrote:
Please excuse my ignorance. I am pretty inexperienced with
XML and Xerces-c. I am working on a project that uses the SAX parser to
extract data from XML files. My problem is that I do not know how to
retrieve the value of an element. My terminology may be wrong so I will
illustrate with an example.
<TEXT selectorcode="STBBA" league="BBA" category="STAT">
<STORYNUMBER>9000-NON-EVENT-MESSAGE-X</STORYNUMBER>
<SELECTORCODE>STBBA</SELECTORCODE>
In the above code, I can determine the element names such as
TEXT, STORYNUMBER, etc. I can also determine the values of attributes
such as the value "BBA" of the league attribute. I am determining both
of these from the startElement function of the DocumentHandler. What I
cannot determine is the data contained within the tags. An example of
this is STBBA between the SELECTORCODE tags. I am sure there must be a
simple way to access this information but after a rather exhaustive
search I cannot seem to find it. Could someone please point me in the
right direction?
The values you're looking for are provided through the characters()
callback function. I would suggest reading a tutorial on SAX parsing
before you attempt to write any code, because there are some issues with
SAX processing that will likely affect your implementation. A good place
to start is the SAX project home page:
http://www.saxproject.org/
By the way, I think you should use the newer SAX2 implementation, rather
than the original SAX implementation. A good SAX tutorial will explain the
differences between SAX and SAX2.
Dave