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:
Shouldn't the text be empty for PLAYER, GUI, and SERVER?
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:
{StartElement} SERVER attributes: 3
{StartElement} GUI attributes: 0
{StartElement} PLAYER attributes: 0
{StartElement} TIME attributes: 1
{EndElement} TIME text: 123
{EndElement} PLAYER text: 123
{EndElement} GUI text: 123
{EndElement} SERVER text: 123
And here is the code:
B4X:
Sub XMLParser_StartElement (Uri As String, element As String, Attributes 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?