0

I try to create an Automator workflow which download images from a website. The name of the images are in a xml file and I want to extract them in order to create an url like http://test.com/images/dynamic_image_name.jpg

I found how to download the images when I have the URL with Automator but I'm looking for a way to parse the XML file in order to extract the images name and generate automatically the good URLs.

Here is a part of the XML file :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Managers</key>
<dict>
    <key>Sophie Barriac</key>
    <dict>
        <key>image</key>
        <string>sophie.png</string>
        <key>Téléphone</key>
        <dict>
            <key>number</key>
            <string>0460046150</string>
            <key>mobile</key>
            <string>0614589665</string>
        </dict>
        <key>Email</key>
        <dict>
            <key>email</key>
            <string>[email protected]</string>
        </dict>
    </dict>
    <key>Kevin Berthier</key>
    <dict>
        <key>image</key>
        <string>kevin.png</string>
        <key>Téléphone</key>
        <dict>
            <key>number</key>
            <string>0469646007</string>
        </dict>
        <key>Email</key>
        <dict>
            <key>email</key>
            <string>[email protected]</string>
        </dict>
    </dict>
</dict>

I saw some things about AppleScript but I know nothing about this. How can I do this ?

0

1 Answer 1

3

Since the XML file you posted is a .plist file, you can use something like this:

tell application "System Events"
    set plistFile to contents of property list file "PATH TO PLIST FILE"

    set managersPlist to property list item "Managers" of plistFile
    set managers to every property list item of managersPlist

    repeat with manager in managers
        set imageFile to value of property list item "image" of manager
        display dialog imageFile
    end repeat
end tell

This will extract all image keys' values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.