Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
info.plist-xmlstarlet不返回指定的节点_Xml_Macos_Info.plist_Xmlstarlet - Fatal编程技术网

info.plist-xmlstarlet不返回指定的节点

info.plist-xmlstarlet不返回指定的节点,xml,macos,info.plist,xmlstarlet,Xml,Macos,Info.plist,Xmlstarlet,我正在尝试使用XMLET解析info.plist(用于iOS应用程序)。我在OSX上用MacBook Pro做这件事。这是我的信息列表: <?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">

我正在尝试使用XMLET解析info.plist(用于iOS应用程序)。我在OSX上用MacBook Pro做这件事。这是我的信息列表:

<?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>UIRequiresFullScreen</key>
    <true/>
    <key>ITSAppUsesNonExemptEncryption</key>
    <false/>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>MinimumOSVersion</key>
    <string>9.3</string>
    <key>CFBundleDisplayName</key>
    <string>My iOS App</string>
    <key>CFBundleIdentifier</key>
    <string>local.nowhere.MyiOSApp</string>
    <key>CFBundleShortVersionString</key>
    <string>3.3.0</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>UISupportedExternalAccessoryProtocols</key>
    <key>UIBackgroundModes</key>
    <array>
        <string>external-accessory</string>
    </array>
    <key>UIAppFonts</key>
    <array>
        <string>FontAwesome.ttf</string>
    </array>
    <key>CFBundleVersion</key>
    <string>321</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <array>
        <string>Location enabled?</string>
    </array>
    <key>NSCameraUsageDescription</key>
    <string>needs access to the camera</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>needs access to photos</string>
    <key>NSCalendarsUsageDescription</key>
    <string>needs access to the calendar</string>
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>needs access to bluetooth</string>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>XSAppIconAssets</key>
    <string>Resources/Media.xcassets/AppIcons.appiconset</string>
    <key>XSLaunchImageAssets</key>
    <string>Resources/Media.xcassets/LaunchImages.launchimage</string>
</dict>
</plist>
以下是输出:

Attempt to load network entity http://www.apple.com/DTDs/PropertyList-1.0.dtd
9.3
My iOS App
local.nowhere.MyiOSApp
3.3.0
321
needs access to the camera
needs access to photos
needs access to the calendar
needs access to bluetooth
UIStatusBarStyleLightContent
Resources/Media.xcassets/AppIcons.appiconset
Resources/Media.xcassets/LaunchImages.launchimage

知道为什么它会返回该级别的所有“字符串”节点吗

您正在匹配
dict
并获取
string
的值,因此它将返回
dict
中的所有字符串

检查是否有值为
CbundLeverVersion
元素,除了选择
dict
(如果该值为真)之外,不会执行任何操作

尝试选择
键本身,然后获取后面第一个同级
字符串的值

xmlstarlet sel --net -t -m "/plist/dict/key[.='CFBundleVersion']" -v "following-sibling::string[1]" ./Info.plist
这将返回:

321

您正在匹配
dict
并获取
string
的值,因此它将返回
dict
中的所有字符串

检查是否有值为
CbundLeverVersion
元素,除了选择
dict
(如果该值为真)之外,不会执行任何操作

尝试选择
键本身,然后获取后面第一个同级
字符串的值

xmlstarlet sel --net -t -m "/plist/dict/key[.='CFBundleVersion']" -v "following-sibling::string[1]" ./Info.plist
这将返回:

321

或者,对于上面运行更快的版本(因为我无法对此发表评论),请不要查找DTD&ignore STDERR:

xmlstarlet sel -t -m "/plist/dict/key[text()='CFBundleVersion']" -v "following-sibling::string[1]" ./Info.plist 2>/dev/null

或者,对于上面运行更快的版本(因为我无法对此发表评论),请不要查找DTD&ignore STDERR:

xmlstarlet sel -t -m "/plist/dict/key[text()='CFBundleVersion']" -v "following-sibling::string[1]" ./Info.plist 2>/dev/null

六羟甲基三聚氰胺六甲醚。。。没有多少帮助。返回:
尝试加载网络实体http://www.apple.com/DTDs/PropertyList-1.0.dtd
@PaulM-哦,是的,对不起。这是因为doctype声明中的系统标识符指向url。尝试在命令行中的
sel
之后添加
--net
(请参阅更新的答案)。我没有这个问题,因为我在测试时没有复制doctype声明。我添加了doctype,复制了错误,然后通过添加
--net
验证了错误的解决。。。没有多少帮助。返回:
尝试加载网络实体http://www.apple.com/DTDs/PropertyList-1.0.dtd
@PaulM-哦,是的,对不起。这是因为doctype声明中的系统标识符指向url。尝试在命令行中的
sel
之后添加
--net
(请参阅更新的答案)。我没有这个问题,因为我在测试时没有复制doctype声明。我添加了doctype,复制了错误,然后通过添加
--net
验证了错误的解决。