1

Consider I have the following data:

let $fruits := <fruits>
    <fruit id="apple" />
    <fruit id="orange" />
</fruits>

how can I use the data in variable $fruits and parse it to become $fruits2 := ('apple', 'orange')?

I have fn:tokenize function in my mind but this only work with string. Thanks in advance for any helps.

2 Answers 2

1

I think this is what you're looking for:

let $fruits2 := $fruits/fruit/@id/data()
Sign up to request clarification or add additional context in comments.

Comments

0

Just to clarify, there are no arrays in XQuery 1.0 and 3.0 only sequences. However, it is looking very likely at the moment that XQuery 3.1 will include an array type.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.