xsd - How to find values using XQuery and plist XML files -
the following sample plist file used question below.
<?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>firstdictionary</key> <dict> <key>string</key> <string>sometext</string> <key>anarray</key> <array> <string>first</string> <string>second</string> </array> </dict> <key>seconddictionary</key> <dict> <key>subdictionary</key> <dict> <key>aboolvalue</key> <false/> </dict> </dict> </dict> </plist>
so question is, since plist (working xcode), keys have element name <key>
, values can , , etc... key-value pair side-by-side (direct siblings)..
is there way using xquery produce value key? retuenvalueforkey(seconddictionary) produce following?
<dict> <key>subdictionary</key> <dict> <key>aboolvalue</key> <false/> </dict> </dict>
my main reference far this link w3schools, not working correctly.
you can in pure xpath, if want wrap in function should work fine too:
declare function local:returnvalueforkey( $key xs:string, $plist element(plist) ) element(dict)? { $plist//key[. = $key]/following-sibling::*[1]/self::dict }; local:returnvalueforkey('seconddictionary', <plist>...</plist>) => <dict> <key>subdictionary</key> <dict> <key>aboolvalue</key> <false/> </dict> </dict>
Comments
Post a Comment