用于键字符串模式的XML XPath
我有一个XML文件,如下所示用于键字符串模式的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 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()