the trick here is that the document is in a namespace so you need to use namespace enabled xpath. For a larger docment especially if you have many documents stored in the DB you may get better results by being more precise and declaring the namespace explicitly in your search such as
declare namespace j="http://marklogic.com/xdmp/json/basic"; //j:constraint-name ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation [email protected] Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Wednesday, October 09, 2013 7:23 AM To: [email protected] Cc: [email protected] Subject: Re: [MarkLogic Dev General] Parsing json query Hi Sini, Please try below code json:transform-from-json($json-query)//*:constraint-name Regards, Asit Nautiyal From: [email protected] [mailto:[email protected]] On Behalf Of sini narayanan Sent: Wednesday, October 09, 2013 4:37 PM To: MarkLogic Developer Discussion Subject: [MarkLogic Dev General] Parsing json query Hi All, I have a json query string and I performed json:transform-from-json($json-query). I get the below output. <json type="object" xmlns="http://marklogic.com/xdmp/json/basic"> <query type="object"> <and-query type="object"> <queries type="array"> <json type="object"> <range-constraint-query type="object"> <constraint-name type="string">country</constraint-name> <value type="array"> <item type="string">FRA</item> </value> </range-constraint-query> </json> <json type="object"> <range-constraint-query type="object"> <constraint-name type="string">TravelType</constraint-name> <value type="array"> <item type="string">TOURISM</item> </value> </range-constraint-query> </json> </queries> </and-query> </query> </json> How do I traverse through the output xml to get each constraint-name node. I tried normal xpath on this output json:transform-from-json($json-query)//constraint-name. But this doesnot work. Please help. Thanks. This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
