I'm making a xml parser for a purpose of challenge. Basically a xml node looks like this:
public struct XmlTag : IXmlTag
{
public IXmlText Name { get; }
public List<IXmlTag> Children { get; }
public Attributes Attributes { get; }
public IXmlText Content { get; }
}
IXmlText
is something, that points into a place in char array.
It worked for some relatively simple xml:
<tag>
<otherTag/>
</tag>
<tag>String</tag>
But it doesn't work like that for xml
<letter>
Dear Mr.<name>John Smith</name>.
Your order <orderid>1032</orderid>
will be shipped on <shipdate>2001-07-13</shipdate>.
</letter>
because the tree structure is not suited to contain mixed content, text and other tags.
My question is which tree structure will be good enough to hold both simple text and other text, preserving the exact order of elements?