Click here to Skip to main content
15,885,365 members
Articles / Programming Languages / XML
Article

XML Editor

Rate me:
Please Sign up or sign in to vote.
4.63/5 (9 votes)
25 Oct 20052 min read 106K   6.1K   72   13
XML Editor with intellisense, automatic tag completion and parsing etc...

Screen Shot 1

Introduction

I have read and downloaded many articles and source code from CodeProject, and now I am trying to payback. Recently I had to develop a small and simple XML editor for a data conversion company. We shall discuss the scenario here.

Before I start, I just want to say that I am a new kid in .NET and the contents of this article/source code are not very professional, it is only for beginners. You may have better or simple ways to establish these goals. Anyway I would love to hear from you. I am very much interested in improving my skills. So, if you have any comments, please drop me a mail or post a feedback.

What is an XML Editor?

As far as I know, an XML editor should have all the necessary functionalities of a text editor, plus some extra functionalities like parsing, Intellisense (showing available tags when user types the '<' symbol), output viewing etc.

How?

To fetch available elements and attributes of XML document, we need to read DTD/Schema (Here I am using DTD). Regular Expression is the easiest way to establish this task, just read DTD using StreamReader and extract elements and attributes using Regular Expression and store them in a DataTable.

In XML, we have elements and attributes. What we want is, when a user presses '<' it should pop a list of elements and the selected tag should be inserted at that location. When the user presses '<' and the '/' symbol, the last opened tag should be closed automatically. This can be done by using the Stack class (which provides a simple last-in-first-out collection of objects).

Screen Shot

Next we want to format the XML file with proper indentation. Here also I use Regular Expressions to solve the issue. Browse the source code for details, it is almost self-describing. Parsing is the next issue, you can do this by simply importing the XML assembly and using the XmlValidatingReader class.

Happy coding....

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
India India
A Software Engineer from Kerala, working in New Delhi, INDIA email: kannan.k.ram@gmail.com | kannankr.in

Comments and Discussions

 
GeneralNice Project Pin
ishwarya mahadevan17-Feb-10 17:33
ishwarya mahadevan17-Feb-10 17:33 
GeneralFunctionality Pin
preneha20-Nov-08 21:40
preneha20-Nov-08 21:40 
QuestionComplex DTDs? Pin
forw15-Nov-06 1:34
forw15-Nov-06 1:34 
QuestionUTF-16 Pin
Play4fun8-Nov-06 2:13
Play4fun8-Nov-06 2:13 
First of all congratulations for the nice job. Very nice project, indeed.
I'm trying to adapt your project to use UT-16 xml files, but i didn't succeded. I'd appreciate your help. Thanks.
GeneralGreat !!! Pin
Mr.No1-Nov-05 3:06
Mr.No1-Nov-05 3:06 
QuestionHow to Syntax Highlighting Pin
HenBlg26-Oct-05 23:45
HenBlg26-Oct-05 23:45 
AnswerRe: How to Syntax Highlighting Pin
Kannan KR30-Oct-05 13:13
Kannan KR30-Oct-05 13:13 
GeneralRe: How to Syntax Highlighting Pin
HenBlg30-Oct-05 17:44
HenBlg30-Oct-05 17:44 
GeneralRe: How to Syntax Highlighting Pin
Abrian P. Stemmet31-Oct-05 20:31
Abrian P. Stemmet31-Oct-05 20:31 
QuestionXML Editor Pin
bbrandin25-Oct-05 22:53
bbrandin25-Oct-05 22:53 
AnswerRe: XML Editor Pin
Kannan KR26-Oct-05 7:29
Kannan KR26-Oct-05 7:29 
GeneralHi Nice Porject! Pin
Jonathan L. Nazario25-Oct-05 12:40
Jonathan L. Nazario25-Oct-05 12:40 
GeneralRe: Hi Nice Porject! Pin
Kannan KR25-Oct-05 13:47
Kannan KR25-Oct-05 13:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.