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 
lingo-l@penworks.com  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to