Previous Up Next

3.7.7  Indent a XML string: xml_print

xml_print takes a string as its only argument, assumes that it contains XML code and indents it for better readability. The indented code is returned as string. The default indent is two spaces.

For example, input:

xml_print("<?xml version=’1.0’?><root><child1>some content</child1><child2></child2><child3/></root>")

Output:

<?xml version='1.0'?>
<root>
  <child1>some content</child1>
  <child2></child2>
  <child3/>
</root>

Input:

s:=export_mathml(1/(x^2+1),display):;
xml_print(s)

Output:

<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'>
  <mfrac>
    <mn>1</mn>
    <mrow>
      <msup>
        <mi>x</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <mn>1</mn>
    </mrow>
  </mfrac>
</math>

Previous Up Next