# XML editor

The XML editor is a tool for creating and viewing XML files

You can use it to perform a variety of tasks such as the following:

- Create new XML files, either from scratch, existing DTDs, or existing XML schemas
- Edit and validate XML files
- Import existing XML files for structured viewing
- Associate XML files with DTDs or XML schemas

To make the XML editor the default editor for XML files, select Window > Preferences > Workbench > File Associations, then select *.xml and XML Editor from the Associated Editors list. Click OK.

The XML editor has two main views - the Source view and the Design view.

#### Source view

The Source view enables you to view and work directly with a file's source code directly.

The Source view has many text editing features, such as syntax highlighting, unlimited undo/redo, and user-defined macros. Another helpful feature is content assist, which uses the information in a DTD or schema content model to provide a list of acceptable continuations depending on where the cursor is located in an XML file, or what has just been typed. The XML editor Source view also includes a "smart" double-clicking behavior. If your cursor is placed in an attribute value, one double-click selects that value, another double click selects the attribute-value pair, and a third double-click selects the entire tag. This makes it easier to copy and paste commonly used pieces of XML.

#### Design view

The XML editor also has a Design view, which represents the XML file simultaneously as a table and a tree. This helps make navigation and editing easier. Content and attribute values can be edited directly in the table cells, while pop-up menus on the tree nodes give alternatives that are valid for that location. For example, the Add child menu item will list only those elements from a DTD or XML schema which would be valid children at that point (as long as grammar constraints are on).

The Design view is especially helpful if you are new to XML, or need to do form-oriented editing. For example, you could use the Create XML File wizard to create a template XML file for a job description form from a job description DTD. After those steps are completed, you would only have to fill in the form data using the Design view.

Note: You can also use the Outline view to insert and delete elements.

> XML editor integration with the workbench
> To edit a file using the XML editor, right-click the file in the Navigator view, and click Open With > XML Editor. Because the editor that is last used to open a file becomes the default editor for that particular file, the XML editor will remain the default XML editor for that file unless you explicitly change it.
> Defining XML editor preferences
> You can set various preferences for the Source view of the XML editor such as the formatter indentation style, line wrapping rules, and content assist rules.

Parent topic: Editing XML files

Related concepts
XML file associations with DTDs and XML schemas

Related tasks
Creating an XML file from scratch
Editing in the Design view
Editing in the Source view

(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.