Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - RE: SAX parse and ISAXContentHandlerImpl Members SAX parse and ISAXContentHandlerImpl MembersTo: NULL Date: 9/2/2005 9:07:00 AM I have an application which takes an XML document and uses a SAX reader to
parse the document. The xml document could have several "empty elements"
like <Value /> or <Value></Value>.
I am currently using the startElement, characters, and endElement methods to
help me determine what to do with the data. My question is, how can I
differentiate between an empty element and an starting element in a
"structure".
<something>
<somethingelse>data</somethingelse>
<anemptyelement />
</something>
I am building a vector list of those data elements through the parser and
these methods. When endElement is called I push the data to the vector if
the data is not an empty string. In the example above <something> does not
have any "data" and the string is empty so I bypass pushing the data to the
vector. The same problem occurs with <anemptyelement /> although I want to
know in the main application that <anemptyelement> was simply blank this time.
Is there a method that would easily distinguish between an empty element and
the other element?
Should I just keep track of the "levels" that I am in? Devise a hack where
<something> would be level 0 and <somethingelse> and <anemptyelement> would
be in level 1. I could add this concept of levels to startElement. I am
hoping for something more elegant.
Thanks for your time...
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
