Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrindia

macrumors newbie
Original poster
May 30, 2013
3
0
Hi:



I got a small project. I'm getting multiple folder from the client containing a small XML file in each. The XML file looks like:



<?xml version="1.0" encoding="UTF-8"?>

<Metadataobject>

<from>thomas.wiedemer@kkmedia.com</from>

<jobname>P2_WT1304g_vier_elemente</jobname>

<priority>2</priority>

<timezone>CEST</timezone>

<year>2013</year>

<month>5</month>

<day>29</day>

<hour>14</hour>

</Metadataobject>



I'm trying to fetch and combine the data from multiple XML files to a single text file and send it as attachment from Microsoft Outlook.



I tried something but can't do:



Code:
set XMLFile to ((choose file) as string)

set documentName to XMLFile & ".txt" as text

set folderPath to "Volumes:Macintosh HD:Users:imac3:Desktop:XML Test:"

tell application "System Events"

    tell XML element 1 of contents of XML file XMLFile

        set myMail to (value of (XML elements whose name is "from")) as string

        set myJob to (value of (XML elements whose name is "jobname")) as string

        set myPriority to (value of (XML elements whose name is "priority")) as string

        set myYear to (value of (XML elements whose name is "year")) as string

        set myMonth to (value of (XML elements whose name is "month")) as string

        set myDay to (value of (XML elements whose name is "day")) as string

        set myHour to (value of (XML elements whose name is "hour")) as string

    end tell

end tell

 

tell application "TextEdit"

    make new document

    set txtMail to "From: " & "        " & myMail & "

"

    set txtmyJob to "Job Name: " & "    " & myJob & "

"

    set txtMyPriority to "Priority: " & "        " & myPriority & "

"

    set txtMyDate to "Date: " & "        " & myDay & "/" & myMonth & "/" & myYear & "

"

    set txtHour to "Hour: " & "        " & myHour

    set text of document 1 to txtMail as text

    make new word at end of document 1 with data txtmyJob & txtMyPriority & txtMyDate & txtHour

    --save document 1 in file ("Volumes/Macintosh HD/Users/imac3/Desktop/XML Test/Test1.txt")

    save document 1 in file (folderPath & documentName)

    close window

    quit

end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.