Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

SAXParser inner XML of entity

Thread view: 
Mize-ze - 12 Jul 2007 08:29 GMT
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
Mize-ze - 12 Jul 2007 13:13 GMT
> Hi,
> Using a SAXParser, how can I get the "inner XML" of entity?
[quoted text clipped - 14 lines]
>
> Thanks

?
Lew - 12 Jul 2007 14:29 GMT
>> Hi,
>> Using a SAXParser, how can I get the "inner XML" of entity?
[quoted text clipped - 16 lines]
>
> ?

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).

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.