Click here to Skip to main content
Click here to Skip to main content

XML Editor

, 25 Oct 2005
Rate this:
Please Sign up or sign in to vote.
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

About the Author

Kannan KR
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 Pinmemberishwarya mahadevan17-Feb-10 17:33 
GeneralFunctionality Pinmemberpreneha20-Nov-08 21:40 
QuestionComplex DTDs? Pinmemberforw15-Nov-06 1:34 
QuestionUTF-16 PinmemberPlay4fun8-Nov-06 2:13 
GeneralGreat !!! PinmemberMr.No1-Nov-05 3:06 
Superb, I am currently working on a project that involves lots of XML data and this is exactly what I was looking for.
 
Many ThanksSmile | :)
QuestionHow to Syntax Highlighting PinmemberHenBlg26-Oct-05 23:45 
AnswerRe: How to Syntax Highlighting PinmemberKannan KR30-Oct-05 13:13 
GeneralRe: How to Syntax Highlighting PinmemberHenBlg30-Oct-05 17:44 
GeneralRe: How to Syntax Highlighting PinmemberAbrian31-Oct-05 20:31 
QuestionXML Editor Pinmemberbbrandin25-Oct-05 22:53 
AnswerRe: XML Editor PinmemberKannan KR26-Oct-05 7:29 
GeneralHi Nice Porject! PinmemberJonathan L. Nazario25-Oct-05 12:40 
GeneralRe: Hi Nice Porject! PinmemberKannan KR25-Oct-05 13:47 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 25 Oct 2005
Article Copyright 2005 by Kannan KR
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid