Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #if !defined isnull
- #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
- #endif
- #define XML. XML_
- new str[256];
- stock XML_Write(File: file, filename[], tag[], tag_msg[], Float: version = 1.0, encoding[] = "us-ascii")
- {
- file = fopen(filename, io_write);
- if(!version) return false;
- else if(isnull(encoding)) return false;
- else if(!file) return printf("Błąd podczas tworzenia pliku \"%s\".", filename);
- filename[strfind(filename, ".xml")] = false;
- format(str, sizeof(str), "<?xml version = \"%.1f\" encoding = \"%s\"?>\n\t<%s>\n\t\t<%s>%s</%s>\n\t</%s>", version, encoding, filename, tag, tag_msg, tag, filename);
- return fwrite(file, str), fclose(file);
- }
- stock XML_Read(File: file, filename[], tag[])
- {
- file = fopen(filename, io_read);
- if(!file) return printf("Błąd podczas tworzenia pliku \"%s\".", filename);
- new buffer[160];
- while(fread(file, buffer))
- {
- if(!strcmp(tag, buffer)) return buffer[strlen(tag)+2]; // +2 = <tag>
- }
- }
- main()
- {
- new File: test;
- printf("HELOŁ.\nZAPISUJEMY...");
- XML.Write(test, "testing.xml", "tag", "ęłęłó", 1.0, "UTF-8");
- printf("HELOŁ.\nODCZYTUJEMY...");
- XML.Read(test, "testing.xml", "tag");
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement