RandomCoder Well-Known Member Licensed User Longtime User Jan 1, 2014 #1 Happy New Year to all. Please can you tell me if there is a way to stop parsing XML once a parameter has been found? Thanks, RandomCoder
Happy New Year to all. Please can you tell me if there is a way to stop parsing XML once a parameter has been found? Thanks, RandomCoder
Erel B4X founder Staff member Licensed User Longtime User Jan 1, 2014 #2 It is not possible to stop the parser. You can however use a global variable to immediately return from each of the parser events. Upvote 0
It is not possible to stop the parser. You can however use a global variable to immediately return from each of the parser events.
RandomCoder Well-Known Member Licensed User Longtime User Jan 1, 2014 #3 Thanks for confirming this Erel. I am working on a UPNP client, my app downloads an XML file then searches for a parameter which once found gets a new XML file to search for more parameters. To do this I've set up another global XML parser. I now need to get more parameters from yet another XML file and so will need another global parser as there is no way to know if the other parsers have finished parsing the remainder of the XML that wasn't required. Is this the best way to proceed or can you advise of a better way? (I hope that makes reasonable sense) Thanks, RandomCoder Upvote 0
Thanks for confirming this Erel. I am working on a UPNP client, my app downloads an XML file then searches for a parameter which once found gets a new XML file to search for more parameters. To do this I've set up another global XML parser. I now need to get more parameters from yet another XML file and so will need another global parser as there is no way to know if the other parsers have finished parsing the remainder of the XML that wasn't required. Is this the best way to proceed or can you advise of a better way? (I hope that makes reasonable sense) Thanks, RandomCoder
warwound Expert Licensed User Longtime User Jan 1, 2014 #4 Have you seen XOM library? With XOM you load an XML document, access it's data using DOM tree traversal and then you're finished with it. It's nothing like the B4A event based XML parser. Martin. Upvote 0
Have you seen XOM library? With XOM you load an XML document, access it's data using DOM tree traversal and then you're finished with it. It's nothing like the B4A event based XML parser. Martin.
RandomCoder Well-Known Member Licensed User Longtime User Jan 1, 2014 #5 warwound said: Have you seen XOM library? With XOM you load an XML document, access it's data using DOM tree traversal and then you're finished with it. It's nothing like the B4A event based XML parser. Martin. Click to expand... No I had not seen this nor did I know that there are different ways of extrapolating XML data. Thank you Martin, I will definitely be having a play with it over the next few days. Cheers, RandomCoder Upvote 0
warwound said: Have you seen XOM library? With XOM you load an XML document, access it's data using DOM tree traversal and then you're finished with it. It's nothing like the B4A event based XML parser. Martin. Click to expand... No I had not seen this nor did I know that there are different ways of extrapolating XML data. Thank you Martin, I will definitely be having a play with it over the next few days. Cheers, RandomCoder
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2014 #6 XmlSax library is based on a SAX parser. As Martin wrote it might be simpler to use a DOM parser in this case. Upvote 0
XmlSax library is based on a SAX parser. As Martin wrote it might be simpler to use a DOM parser in this case.
U urikupfer Member Licensed User Longtime User Jan 2, 2014 #7 You can run the SaxParser (define it in a class) ,with a thread (the thread library) , surround the call with try catch, and in the SaxParser event throw exception (ExceptionEx from thread library), whenever you want. It worked for me very well. Upvote 0
You can run the SaxParser (define it in a class) ,with a thread (the thread library) , surround the call with try catch, and in the SaxParser event throw exception (ExceptionEx from thread library), whenever you want. It worked for me very well.