Search code examples
phpiosxmlplist

grab data from .plist ios in PHP


so this is the plist

<?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>New item</key>
    <array>
        <dict>
            <key>assets</key>
            <array>
                <dict>
                    <key>kind</key>
                    <string>software-package</string>
                    <key>url</key>
                    <string>http://down.weapp.com/apps/zb/002/43/12/21/58cae8840ba0628e304b1118.ipa</string>
                </dict>
                <dict>
                    <key>kind</key>
                    <string>display-image</string>
                    <key>needs-shine</key>
                    <true/>
                    <key>url</key>
                    <string>http://www.weapp.com/picture/app_ios/cn/002/43/12/21/57x57bb.png</string>
                </dict>
                <dict>
                    <key>kind</key>
                    <string>full-size-image</string>
                    <key>needs-shine</key>
                    <true/>
                    <key>url</key>
                    <string>http://www.weapp.com/picture/app_ios/cn/002/43/12/21/512x512bb.png</string>
                </dict>
            </array>
            <key>metadata</key>
            <dict>
                <key>bundle-identifier</key>
                <string>com.xiaoji.gamecenter</string>
                <key>bundle-version</key>
                <string>1.5.2</string>
                <key>kind</key>
                <string>software</string>
                <key>title</key>
                <string>小鸡模拟器</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>

and i want to grab the .ipa url, to do this i am using simplexml

$xml=simplexml_load_string($plistString)

now i would access it doing

$xmlPlist->dict->array[0]->string,

but there are 2 strings there, how can i access the url one? now this is confusing for me, am i even accessing the plis in the correct way? should i mention every "dict" there is?


Solution

  • Try this:

    echo $xml->dict->array->dict->array->dict->string[1];