Introduction
The first paragraph
Another long paragraph
fr: After the cut, I obtain:
en: Après avoir coupé, j'obtiens :
Introduction
The first paragraph
[]
[div]
[div, div]
[div, div, p]
Introduction
[div, div]
[div]
[div, p]
The first paragraph
[div]
[div]
[div, p]
Another long paragraph
[div]
[]
en: The algorihm, is then really simple:
fr: L'algorithme est alors très simple :
let res be the XML as a string ;
read res and each time you encouter a tag:
if it is an opening one:
push it to the stack
else if it is a closing one:
pop the stack.
remove any malformed/cutted tag in the end of res
for each tag in the stack, pop it, and write:
res = res + closed tag
return res
en: And `res` contain the repaired XML.
fr: Et `res` contiend le XML réparé.
en: Finally, this is the code in ruby I use. The `xml` variable contain the cutted XML.
fr: Finallement, voici le code en ruby que j'utilise. La variable `xml` contient le XML coupé.
# repair cutted XML code by closing the tags
# work even if the XML is cut into a tag.
# example:
# transform '