The following code prints the description and title of each doc:
Sub Process_Globals
Dim parser As SaxParser
Dim currentName As String
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
parser.Initialize
Dim in As InputStream
in = File.OpenInput(File.DirAssets, "test.txt")
parser.Parse(in, "xml")
in.Close
End Sub
Sub xml_StartElement (Uri As String, Name As String, Attributes As Attributes)
'check if we are in 'str' node inside a 'doc' node.
If Name = "str" AND parser.Parents.IndexOf("doc") > -1 Then
currentName = Attributes.GetValue2("", "name")
End If
End Sub
Sub xml_EndElement (Uri As String, Name As String, Text As StringBuilder)
If Name = "str" AND parser.Parents.IndexOf("doc") > -1 Then
Select currentName
Case "description"
Log("Description: " & Text.ToString)
Case "title"
Log("Title: " & Text.ToString)
End Select
End If
End Sub
The result:
Description: A collection of theatrical trailers for the Basil Rathbone-Nigel Bruce "Sherlock Holmes" films.
Title: Sherlock Holmes Trailers
Description: Based on the Sir Authur Conan Doyle story "The Dancing Men", Sherlock Holmes and Dr. Watson are placed in WWII europe to help protect a scientist and his invention from the Nazis. Basil Rathbone .... Sherlock Holmes Nigel Bruce .... Dr. John H. Watson Lionel Atwill .... Professor Moriarty Kaaren Verne .... Charlotte Eberli William Post Jr. .... Dr. Franz Tobel Dennis Hoey .... Inspector Lestrade Holmes Herbert .... Sir Reginald Bailey Mary Gordon .... Mrs. Hudson
Title: Sherlock Holmes and the Secret Weapon
Description: The New Adventures of Sherlock Holmes "The Case of Lady Beryl" Originally aired October 25, 1954. Lady Beryl admits to a crime she did not commit. Holmes not only reveals the true murderer, but Lady Beryl's motive for lying about the crime.
Title: Sherlock Holmes - The Case of Lady Beryl
Description: Failed pilot for a proposed British Sherlock Holmes series starring John Longdon (Hitchcock's "Blackmail" and "The Skin Game") as Sherlock Holmes. Campbell Singer plays Dr Watson and the episode also features Walter Gotell (70s and 80s Bond pictures) as Luzatto. The story is based on the canonical adventure "The Man With The Twisted Lip".
Title: Sherlock Holmes - The Man Who Disappeared (Failed Pilot)