Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
<name_day>
<Onomastikes>
<Month>4</Month>
<Day>23</Day>
<Name> George </Name>
i want to match the current system date(month-day) with (month+day) from the xml file and after with database first_name
i have the xml file and i pass the data to array and then to datagrid2 (always unicode data).
i do not mind if i get it from xml or the datagrid,i am looking the easy way for now to learn it..
on mouseUp
set the itemDelimiter to slash
local tPreferencesFile
put item 1 to -2 of the effective filename of this stack & "/birthdays.xml" into mypath
--set the itemDelimiter to comma
# Read the preferences data from the file into a variable. Always check for the result when reading files
# as its possible that the file may have been deleted or moved.
local tPreferencesData, tResult
put url ("file:" & mypath) into tPreferencesData
put the result into tResult
if tResult is not empty then
answer error "Failed to read preferences file at location: " & mypath
return empty
end if
put tPreferencesData into theXML
replace cr with empty in theXML
-- Convert xml to array. Store data in array as UTF8.
put ConvertXMLToArray(theXML, "UTF-8") into theArray -- handler in RevOnline stack
-- Convert to an array that can be assigned to the dgData of a Data Grid (numerically indexed).
put SortArrayKeysWithXMLOrdering(theArray["birthdays"]) into theKeys -- handler in RevOnline stack
put 0 into i
repeat for each line theKey in theKeys
add 1 to i
put theArray["birthdays"][theKey] into theData[i]
end repeat
set the dgdata of group "datagrid1" to theData
--breakpoint -- check values of arrays in debugger
end mouseUp
On MouseUp
put revXMLCreateTreeFromFile("birthdays.xml",false,true,false) into XML-ID
#XML-ID is the id of a new xml tree
if the result is not empty then
answer error "Failed to read preferences file"
exit
end if
#... your code
End MouseUp
now you can explore easily your XML with the XMl library that is included in Livecode. (See Dictionary -> Library -> XML)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
thank you maxv but the anwser you give is included in my code abobe..
i know to get the data from xml,and to put it if i want in datagrid or array.
I do not know how to match the data from xlm or the datagrid with system date.
#create an array that KEY are names and values are dates
#all dates in array formatted like DD-MM-YYYY or your system date
put the system date into today
put 0 into check
put false into verify
repeat for each item tempItem of myArray
add 1 to t
if tempItem = today then
put true into check
exit repeat
end if
end repeat
if check then
put myArray[t] into nameday
answer "today is nameday of " & nameday
end if
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w