SAX: Short tag's ...

T

Thomas Lehmann

Hi!

Is there a way to recognize short tags in a XML?
I'm implementing a SAX handler...

Problem: storing the XML code I would need this information
in the startElement ...

How can I handle this?

<element id="abc" />
<element id="xyz" >any text</element>
 
D

Diez B. Roggisch

Thomas said:
Hi!

Is there a way to recognize short tags in a XML?
I'm implementing a SAX handler...

Problem: storing the XML code I would need this information
in the startElement ...

How can I handle this?

<element id="abc" />
<element id="xyz" >any text</element>

I don't think there is a (standard) way, and it shouldn't matter (unless you
are actually talking about HTML, where sadly enough it does).

In XML, <foo></foo> is the exact same thing as <foo/>.

Or do you need to *write* XML with shortened tags?

Diez
 
D

David Smith

Thomas said:
Hi!

Is there a way to recognize short tags in a XML?
I'm implementing a SAX handler...

Problem: storing the XML code I would need this information
in the startElement ...

How can I handle this?

<element id="abc" />
<element id="xyz" >any text</element>

So ... are you writing as you read? If so, I'm not sure you can know
which form to write out immediately. Best bet would be to delay write
until the next SAX event. The next SAX event will tell if the element
should be written as <element /> or <element>.

--David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top