FAQ
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>

Search Discussions

  • Diez B. Roggisch at Oct 5, 2009 at 3:02 pm

    Thomas Lehmann wrote:

    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
  • David Smith at Oct 8, 2009 at 1:27 am

    Thomas Lehmann wrote:
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedOct 5, '09 at 2:23p
activeOct 8, '09 at 1:27a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase