Get XML Attributes in SPIN

laurent974laurent974 Posts: 67
edited 2016-04-28 - 14:08:49 in Learn with BlocklyProp
I would like to share a little code after my first journey on the SPIN road.
I didn't find an xml parser for the propeller. But my need wasn't so difficult to code. I just wanted to get the attributes of an xml file.
Since it took me some time to get it right, I post it here it may help others, or you could give me advices to improve it too.

i didn't count how many time i was lost in pointer / address / values with spin. Only using the terminal to debug is really a pain.

┌---------------------------------------------------------------------------------------------------┐
| This Obj finds XML attributes and put them into a list of string                                  |
| suppose you have an xml text that provides informations inside attributes like                      |
|                                                                                                   |
|                 <test>                                                                            |
|                    <Day data="Auj">                                                               |
|                    <Day data="Tom">                                                               |
|                 </test>"                                                                          |
|                                                                                                   |
|  GetXMLATTRIBs will extract all attributes values. Results are stored into a array of strings.    |
|                                                                                                   |
|  Days  = "Auj\0Tom\0"                                                                             |
|                                                                                                   |
└---------------------------------------------------------------------------------------------------┘

           ┌--> get starting position
┌───────-┐ │                                                                    ┌---> Days
│ xmltxt │-┘         |                                                          │
└──────-─┘ │                     ┌--store in global value--┐  dispatch function │
           └--> ParseXMLTxt ---> |     Values_Array        │--------------------┼---> Conditions
                                 └-------------------------┘   GetXMLAttribs    │
                                                                                │
                                                                                └---> Icons

NOTE: This file uses a modified version of OBJ string. I added a string copy function
Sign In or Register to comment.