Bug? iXmlSax - EndElement text node error

Discussion in 'iOS Bugs & Wishlist' started by Scott Bartgis, May 1, 2015.

  1. Scott Bartgis

    Scott Bartgis Member Licensed User

    I come from the XML DOM parsing world, but rather than wait or invent something from scratch, I am using SAX in my application.

    My question is with the text values received in an EndElement event. It seems to include the text node with every end element, if the last element had one.

    Example XML String:

    <SERVER PRODUCT="model1" ZONE="1" VER="1.0" ><GUI><PLAYER><TIME TYPE="elapsed">123</TIME></PLAYER></GUI></SERVER>

    When run through SAX, here is what is logged:

    And here is the code:
    Code:
    Sub XMLParser_StartElement (Uri As String, element As StringAttributes As Map)
        
    Log("{StartElement} " & element & " attributes: " & Attributes.Size)
    End Sub

    Sub XMLParser_EndElement (Uri As String, element As String, xText As StringBuilder)
        
    Log("{EndElement} " & element & " text: " & xText.)
    End Sub
    Shouldn't the text be empty for PLAYER, GUI, and SERVER?
     
  2. Scott Bartgis

    Scott Bartgis Member Licensed User

    Just had an idea to try out other text nodes in the child elements, and as I feared, those are ignored. Only the last text is being provided.

    XML: SERVER PRODUCT="model1" ZONE="1" VER="1.0" ><GUI>Hello world!<PLAYER><TIME TYPE="elapsed">123</TIME></PLAYER></GUI></SERVER>

    Output is the exact same as above example. "Hello world!" never comes back in the EndElement.

    I am fairly sure that this XML structure is allowed.

    http://stackoverflow.com/questions/...tain-text-and-child-elements-at-the-same-time
     
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Scott Bartgis

    Scott Bartgis Member Licensed User

    Thank you Erel! The output is now what is expected.
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice