Run this in your message window:
play movie "http://www.dmillerstudios.com/temp/XMLObjectStorage.dir"
The movie contains a script that will convert a prop list to and from
XML. The list can contain the following data types:
void, integer, float, string, symbol, point, linear list, prop list,
color( rgb or palette index), date, member, cast lib, sprite, and xtra.
On Jan 26, 2006, at 9:46 AM, Mathieu Sénidre wrote:
Hi Michael,
I wrote this script some time ago, not really *heavily* tested yet but
works
nicely so far. Put the code in a movie script, then you can convert
your
propList into XML by doing
xmlString = propListToXML(myPropList)
xml nodes will have a "ilk" attribute, which is used by the
xmlToPropList
function to set the correct types (string, list, symbol etc...)
for xmlToPropList you have to parse your xml using the parser Xtra,
make a
propList with it and provide that as input to the xmlToPropList
function.
-----------------------------------------------
on propListToXML mList, mSub
crlf = numToChar(13) & numToChar(10)
tFile = ""
if voidP(mSub) then
tFile = openXMLnode(tFile, "xml") & crlf
end if
tCount = mList.count
repeat with i = 1 to tCount
tNode = mList.getPropAt(i)
tIlk = ilk(mList[i])
if (tIlk = #propList) then
tFile = openXMLnode(tFile, tNode) & crlf
tFile = tFile & propListToXML(mList[i], 1)
tFile = closeXMLnode(tFile, tNode)
else
ilkStr = string(tIlk)
ilkStr = QUOTE & ilkStr.char[1..3] & QUOTE
tString = string(tNode) && "ilk=" & ilkStr
tFile = openXMLnode(tFile, tString) & mList[i]
tFile = closeXMLnode(tFile, tNode)
end if
end repeat
if voidP(mSub) then
tFile = closeXMLnode(tFile, "xml")
end if
return tFile
end
-- input is meant to be a propList from the xml parser Xtra
"makePropList"
method
on xmlToPropList mData
tList = [:]
tCount = mData.child.count
repeat with i = 1 to tCount
tNode = symbol(mData.child[i].name)
if mData.child[i].child.count then
val = xmlToPropList(mData.child[i])
else
val = mData.child[i].charData
tIlk = mData.child[i].attributes.ilk
case tIlk of
"str":nothing
"int":val = integer(val)
"flo":val = float(val)
"sym":val = symbol(val)
OTHERWISE: val = value(val)
end case
end if
tList.addProp(tNode, val)
end repeat
return tList
end
on openXMLnode mFile, mNodeName
-- crlf = numToChar(13) & numToChar(10)
mFile = mFile & "<" & mNodeName & ">" -- & crlf
return mFile
end
on closeXMLnode mFile, mNodeName
crlf = numToChar(13) & numToChar(10)
mFile = mFile & "</" & mNodeName & ">" & crlf
return mFile
end
-------------------------------------------------
Hope this helps !
Selon Michael von Aichberger 2 <[EMAIL PROTECTED]>:
Hi List!
The XML Parser Xtra converts XML-formatted text into a Lingo property
list.
Now, I need to do the opposite: I have a property list and would like
to
convert that into an XML text.
--
Mathieu Sénidre
MatseMedia
Développement multimédia online/offline
tel 06 79 52 19 77
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list,
email [email protected] (Problems, email
[EMAIL PROTECTED]). Lingo-L is for learning and helping with
programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]