Xml editor by string selection

I’m trying to make a text editor that will be limited by css formatting

Basically i’m looking for a way to edit xml that is turned into a string by inserting xml tags by selection in the string and then clean up the string so that it has nice xml formmating.

It would then only be a step from there to create a list of xml tags that would correspond to css names for formatting the XML string and then adding the css styles and displaying this.

Thus creating a css limited text editor

I have looked everywhere on this issue of an xml string formatting by selection and have gotten so far along on my own creation but am finding it hard to move on any further.

does anyone have any ideas about how i could do this ?

thanks
Shane