You can translate the question and the replies:

How to get result in array or registered ?

``` SELECT xpath ( cast ('xml', '<?xml version="1.0" encoding="ISO-8859-1"?> <a> <b>Hello</b> <b>World</b> </a>' ) , '/a/b/text()', false) as xpath_results FROM Dual(); ``` The result is ``` xpath_results HelloWorld ``` I want result like ``` xpath_results [Hello,World] ``` What should I need to do ? I don't want to use xml data source. Can I get this result using XPATH query OR XMLquery?
user
01-04-2019 16:06:34 -0400

3 Answers

Hello, In order to get your expected output, I would use the SPLIT and XMLQuery function to query XML elements of a particular path in array type. For example: ``` SELECT SPLIT(',', XMLQUERY('for $str in //a/b return string-join($str/text(), ",")', false, '<?xml version="1.0" encoding="ISO-8859-1"?> <a><b>Hello</b> <b>World</b></a>', false)) FROM DUAL(); ``` For more details, refer to the functions [XMLQUERY](https://community.denodo.com/docs/html/browse/7.0/vdp/vql/appendix/syntax_of_condition_functions/xml_processing_functions#xmlquery) and [SPLIT](https://community.denodo.com/docs/html/browse/7.0/vdp/vql/appendix/syntax_of_condition_functions/text_processing_functions#split) in the Virtual DataPort VQL Guide. Hope this helps!
Denodo Team
02-04-2019 05:44:37 -0400
Still I didn't got result with , seprated
user
 Edited on: 02-04-2019 10:31:23 -0400
Hi, In order to get the results in a Array with 'comma' separated values, I would do the following Text Manipulation: ``` SELECT split(';',substr(XMLQUERY('for $str in //a/b return concat($str,",")', false, '<?xml version="1.0" encoding="ISO-8859-1"?> <a><b>Hello</b> <b>World</b></a>', false),0,len(XMLQUERY('for $str in //a/b return concat($str,",")', false, '<?xml version="1.0" encoding="ISO-8859-1"?> <a><b>Hello</b> <b>World</b></a>', false)))) FROM DUAL(); ``` This, way a 'comma' will be added between the Words. Hope this helps!
Denodo Team
26-06-2019 02:06:07 -0400
You must sign in to add an answer. If you do not have an account, you can register here