It works. I’ll go with the second solution. Martin, thanks a lot!
> Am 26.08.2017 um 12:26 schrieb Martin Honnen <
martin.honnen@gmx.de>:
>
> On 26.08.2017 12:23, Günter Dunz-Wolff wrote:
>
>> I’m trying to get data out of json via xquery.
>> This is my scenario:
>> 1. Fetching data with fetch:text() calling a REST-API
>> 2. Transforming the data with json-to-xml, so I’ll get something like
>> <array xmlns="
http://www.w3.org/2005/xpath-functions“>
>> <map>
>> <string key=„word1“>gehen</string>
>> ...
>> </map>
>> ...
>> </array>
>> 3. In my xqm-file I have: let $json_xml := json-to-xml(my_fetched_json)
>> 4. I try to get „gehen“ with $json_xml//string[@key='word1‘], but it yields nothing, also $json_xml//string yields nothing. Only $json_xml//text() yields all string-values into a long string.
>> What am I doing wrong? Or is there another way, to work with JSON-Data to get values of a given key?
>
> The elements are in the namespace
http://www.w3.org/2005/xpath-functions so either use
> $json_xml//*:string[@key='word1']
> or make sure you declare a prefix (e.g. 'fn') for the namespace and use that prefix in e.g.
> $json_xml//fn:string[@key='word1']
>