Re: SAXParser inner XML of entity
Mize-ze wrote:
On Jul 12, 10:29 am, Mize-ze <zahy.bn...@gmail.com> wrote:
Hi,
Using a SAXParser, how can I get the "inner XML" of entity?
for example:
Let's say this is my XML:
<foo>
<bar att="">some text </bar>
</foo>
and I want to get the string "<bar att="">some text </bar>" .
If I am extending a DefaultHandler I have access to events for start/
endElement and characters.
but what about just getting the inner xml of an entity?
Thanks
?
First of all, I am not clear why you answered your own first post.
I am going to guess what you mean by "'inner XML' of entity"; the phrase
conveys no meaning to me. Do you want to know how to process nested tags?
When the startElement() method is called, it gives you the tag name (possibly
with namespace). That tells you which tag you're processing. When I write
SAX parsers I write a separate parser class for each tag and maintain a holder
that keeps track of the current parser object. That object maintains a
reference to the parser for its enclosing tag so I can tell the difference
between, for example, the "address" tag inside a "person" and one inside an
"organization".
That may be too complicated at first, in which case you might use a parser
class that maintains an internal state machine or other construct for all
possible tags in the document, then farms out to (private) methods the logic
for each different tag. You might have a handleFoo() and a handleBar() in
your class. Your startElement() would call the appropriate method depending
on the tag argument (localName or qName).
--
Lew