XML : Each result on a new line Xquery

I know there is similar question asked but the solution given in that did not solve my issue. And since I have less reputation I am unable to comment on the same question page.

My Xquery code:

   <results>      {          for $p in          (          for $o in doc("mondial-3.0.xml") /mondial/organization          where fn:count($o/members)          order by fn:count($o/members) descending          let $m := $o/members          return <organization>                  <name> {$o/@name/string()} </name>                  <abbreviation> {$o/@abbrev/string()} </abbreviation>                  <num_members> {fn:count($o/members)} </num_members>                   <country> {doc("mondial-3.0.xml")/mondial/country[@id=$m/@country]/@name/string()} </country>             </organization>          )[position() < 3]          return $p      }      </results>    

I am using Zorba as the Xquery engine for getting the output. The output which i am getting is correct, just that structure of my output is not the way I want it to be.

Currently all the countries are getting printed on the same line.

  <country> Angola Argentina Bolivia.... </country>    

But I want each new country to be on a new separate line.

  <country> Angola </country>  <country> Argentina</country>  <country> Bolivia </country>    

XML file:

https://raw.githubusercontent.com/kroell/hsrm-mi-2semester-markuplanguage/master/Abgabe2/Aufgabe2/mondial-3.0.xml

No comments:

Post a Comment