Am 19.02.2020 um 15:08 schrieb thufir:
How can I start a new "record" and then nest tags in that record?


but I'm getting output like:

<xml>
  <record>
      if (matches($line, "[0-9]"))
      then <data>people</data>
      else <name>people</name>
  </record>
  <record>
      if (matches($line, "[0-9]"))
      then <data>joe</data>
      else <name>joe</name>
  </record>
..

wheras I just want output like:

<record>
  <name>joe</name>
  <data>123</data>
</record>


the query:

xquery version "3.0";

<xml>
{
for $line in db:open("foo.txt")//text()
return
        <record>


Nest any contained expression in further curly braces

  {

      if (matches($line, "[0-9]"))
      then <data>{$line}</data>
      else <name>{$line}</name>


}

</record>
}
</xml>






Reply via email to