Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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
用于键字符串模式的XML XPath_Xml_Xpath_Xml Parsing - Fatal编程技术网

用于键字符串模式的XML XPath

用于键字符串模式的XML XPath,xml,xpath,xml-parsing,Xml,Xpath,Xml Parsing,我有一个XML文件,如下所示 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBun

我有一个XML文件,如下所示

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
    <dict>
        <key>CFBundleExecutable</key>
        <string>p4v</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>2018.2</string>
        <key>CFBundleVersion</key>
        <string>2018.2/1666551</string>
        <key>CFBundleGetInfoString</key>
        <string>2018.2, Copyright 2018 Perforce Software, Inc.</string>
        <key>CFBundleIconFile</key>
        <string>application.icns</string>
        <key>P4RevString</key>
        <string>P4V/MACOSX1013X86_64/2018.2/1666551 (2018/05/30)</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
        <key>NSHighResolutionCapable</key>
        <string>True</string>
        <key>CFBundleName</key>
        <string>P4V</string>
        <key>CFBundleSignature</key>
        <string>P4VC</string>
        <key>CFBundleIdentifier</key>
        <string>com.perforce.p4v</string>
    </dict>
</plist>
但它不起作用

试试这个XPath:

/plist/dict/key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()
其结果是
2018.2

/plist/dict/key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()