XML/Output: Difference between revisions

Content added Content deleted
m (Removed stray newline)
Line 1,271: Line 1,271:
print(root)</lang>
print(root)</lang>
{{out}}
{{out}}
<pre><CharacterRemarks>
<lang xml><CharacterRemarks>
<Character name="April">Bubbly: I&apos;m &gt; Tam and &lt;= Emily</Character>
<Character name="April">Bubbly: I&apos;m &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O&apos;Shanter">Burns: &quot;When chapman billies leave the street ...&quot;</Character>
<Character name="Tam O&apos;Shanter">Burns: &quot;When chapman billies leave the street ...&quot;</Character>
<Character name="Emily">Short &amp; shrift</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks></pre>
</CharacterRemarks></xml>
Note also that LuaXML escapes quote marks and apostrophes, which makes the output slightly different to the task requirement. This can be 'fixed' if necessary using Lua's in-built string.gsub function:
Note also that LuaXML escapes quote marks and apostrophes, which makes the output slightly different to the task requirement. This can be 'fixed' if necessary using Lua's in-built string.gsub function:
<lang Lua>xmlStr = xml.str(root):gsub("&apos;", "'"):gsub("&quot;", '"')
<lang Lua>xmlStr = xml.str(root):gsub("&apos;", "'"):gsub("&quot;", '"')
print(xmlStr)</lang>
print(xmlStr)</lang>
{{out}}
{{out}}
<pre><CharacterRemarks>
<lang xml><CharacterRemarks>
<Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks></pre>
</CharacterRemarks></xml>


=={{header|Mathematica}}==
=={{header|Mathematica}}==