Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > SAXParser inner XML of entity

Reply
Thread Tools

SAXParser inner XML of entity

 
 
Mize-ze
Guest
Posts: n/a
 
      07-12-2007
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

 
Reply With Quote
 
 
 
 
Mize-ze
Guest
Posts: n/a
 
      07-12-2007
On Jul 12, 10:29 am, Mize-ze <(E-Mail Removed)> 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


?

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      07-12-2007
Mize-ze wrote:
> On Jul 12, 10:29 am, Mize-ze <(E-Mail Removed)> 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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
Entity Name or Entity Number? Samuel van Laere HTML 4 02-24-2007 10:11 PM
Determine encoding of XML file with xerces-c and SAXParser christian.eickhoff@nt.uni-saarland.de XML 2 01-25-2007 10:01 AM
Problems with SAX parser in Java (SAX2 driver class javax.xml.parsers.SAXParser found but cannot be loaded) Per Magnus L?vold Java 0 11-16-2004 04:02 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM



Advertisments