title: Using xml-functions in h2 database for university project
body: <p>For my university-project I installed an h2database locally on my computer. I have a little data in it and now I am trying to export parts of this data via the included xml-functions that h2 offers.</p>
  <p>However  I do not really get how this works. I am working with SQL Workbench/J to test and after it works I implement it in my java program.</p>
  <p>For example I have the XMLNODE-function which works like this (taken from the h2 manual):</p>
  <pre><code>XMLNODE(elementString [, attributesString [, contentString [,indentBoolean]]])
  </code></pre>
  <p><em>Create an XML node element. An empty or null attribute string means no</em>
  <em>attributes are set. An empty or null content string means the node is</em>
  <em>empty. The content is indented by default if it contains a newline. This</em>
  <em>method returns a string.</em>
  <em>Example:</em></p>
  <pre><code>CALL XMLNODE('a', XMLATTR('href', '``https://h2database.com``'), 'H2')
  </code></pre>
  <p>So when I call <code>CALL XMLNODE('a', XMLATTR('href', 'https://h2database.com'), 'H2')</code>
  I get:</p>
  <pre><code>&lt;a href=&quot;https://h2database.com&quot;&gt;H2&lt;/a&gt;
  </code></pre>
  <p>all fine...</p>
  <p>But when I only use the XMLNODE without the XMLATTR like this: <code>CALL XMLNODE('a',  'H2');</code> I get the following output:</p>
  <pre><code>&lt;aH2/&gt; 
  </code></pre>
  <p>So I dont know what I am doing wrong cause I do not even come to the point where I can put some data in it cause when I only use the NODE it does not seem like good xml^^</p>
  <p>Btw: When I am trying to get the resultset via my java program it just tells me that there is no data.
  here is the code:</p>
  <pre><code>s = conn.createStatement();
  String query = &quot;CALL XMLNODE('test1', XMLATTR('test2', 'test3'), 'test4');&quot;;
  rs = s.executeQuery(query);
  
  
  String val = rs.getString(1);
  System.out.println(val);
  </code></pre>
  <p>The explanation in the manual says that it is returning a String</p>