Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new str[128];
- new XMLNode: banksDoc = xmlLoadFile("scriptfiles/mixed.xml"); // Load a xml
- if (!banksDoc){ // If could not be loaded
- xmlLastErrorDesc( str ); // Get error description
- new lastrow = xmlLastErrorRow(); // Get error row
- new lastcol = xmlLastErrorCol(); // Get error col
- printf("%s ( Row: %d ) (Col: %d)",str,lastrow,lastcol); // print it
- return 1; // exit function
- }
- // If loaded successfully
- /*
- Mixed.xml content:
- <mixed>
- <businness>
- <property type="1" x="" y="" z="">4Dragon's Casino</property>
- </businness>
- <house>
- <property type="0" x="" y="" z="">Dynamic House</property>
- </house>
- <police>
- <property type="2" x="" y="" z="">LSPD</property>
- </police>
- <banks>
- <bank type="1" x="" y="" z="">Bank 1</property>
- <bank type="2" x="" y="" z="">Bank 2</property>
- <bank type="3" x="" y="" z="">Bank 3</property>
- <bank type="1" x="" y="" z="">Bank 4</property>
- </bank>
- </mixed>
- */
- // How can we get banksDoc ?
- // Easy only while loop.
- new XMLNode: banksNode = xmlFindChild (banksDoc, "banks");
- new XMLNode: propertyNode ;
- new i = 0;
- while ( (propertyNode = xmlFindChild(banksNode, "bank", i)) ){ // if bank exists in the current idx
- xmlNodeGetAttribute (propertyNode,"type",str); // Copy type attr to str
- new type = strval(str);
- xmlNodeGetAttribute (propertyNode,"x",str); // Copy x pos to str
- new Float:x = floatstr(str);
- xmlNodeGetAttribute (propertyNode,"y",str); // Copy y pos to str
- new Float:y = floatstr(str);
- xmlNodeGetAttribute (propertyNode,"z",str); // Copy z pos to str
- new Float:z = floatstr(str);
- xmlNodeGetValue(propertyNode, str); // Copy tag content (in this case Bank Name) to str
- CreateBank (type,x,y,z,str); // It's not SAMP function...Just example
- i++;
- }
- xmlUnloadFile(banksDoc); // Unload it, It's really important to delete it from memory...
- printf(" %d Bank loaded ", i);
Advertisement
Add Comment
Please, Sign In to add comment