// Collection of code snippets by Arne Vajhøj
// posted to eksperten.dk, usenet and other places (2002-now)
using System;
using System.IO;
using System.Xml;
class MainClass
{
public static void Main(string[] args)
{
string s = "ikke talehvem tror du der svare
sikkert arne_v";
MyXmlTextReader xtr = new MyXmlTextReader(s);
while(xtr.More)
{
XmlDocument doc = new XmlDocument();
doc.Load(xtr);
doc.Save(Console.Out);
}
}
}
class MyXmlTextReader : XmlTextReader
{
private int len;
private int last;
private bool more;
public MyXmlTextReader(string s) : base(new StringReader(s))
{
len = s.Length;
last = 0;
more = true;
}
public bool More
{
get
{
return more;
}
}
public override bool Read()
{
if(last > 0 && Depth == 0)
{
last = 0;
if(LinePosition >= len - 3) more = false;
ResetState();
return false;
}
else
{
last = Depth;
return base.Read();
}
}
}