BYU Home page BRIGHAM YOUNG UNIVERSITY  
Search BYU 
Using a Text Editor (like Notepad, WordPad, Emacs, or vi) to Edit XML
Table of Contents
Go Down to Content

    Learn how to use your favorite text editor to edit XML.

    Here, you’ll find a short list of instructions about how to use any old plain text editor on any operating system to easily create XML documents. assuming that you already know how to use the text editor and operating system of your choice to create and save other types of text files.

    Creating a New XML File
    It is important that all the XML files for your ECEn XML web pages have a file extension of .xml and ONLY .xml. In theory, this is an easy thing to do. Just make sure you give your filename an .xml extension.

    Windows can complicate this. Sometimes, when you’re not looking, Windows will append extra extensions, such as .txt or .rtf, to your XML files when you use Notepad or WordPad to edit XML. If you’re using Notepad, when you save, be sure to set the ‘Save as Type’ to ‘All Files’. If you’re using WordPad, set ‘Save as Type’ to ‘Unicode Text Document’. If you’re working with a sample file you’ve downloaded, you shouldn’t have to worry about saving as a certain type unless you ‘Save As’.

    My files don’t seem to have any extension. By default, Windows will hide most file extensions, including .xml. To change this:

    1
    Open a Windows Explorer window. (Start -> My Computer)
    2
    Open up the Tools menu along the top.
    Finding the Tools menu
    [image]
    3
    Choose Folder Options.
    4
    Click on the View tab.
    5
    Look though the list of ‘Advanced settings:’ and uncheck ‘Hide extensions for known file types’.
    Turning off 'Hide extensions for known file types'.
    [image]
    6
    Click ‘Apply’ and ‘OK’.
    7
    You’ll then see the .xml on the end of your file and if there is an extra .txt or .rtf, you’ll be able to easily see that as well.

    Writing Your XML
    Once you’ve got a new XML file to work with, just type out the XML to define your ECEn web page. If you’ve never written any ECEn web XML before, have a look at the Howdy, World tutorial. It will lead you through creating a simple page, teaching you the basics of writing XML and setting up ECEn XML web pages.

    If you’re looking for how to create links, tables, picture or any other kind of common web page content, we have a number of Common Tasks that you might find helpful. All of them have sample XML to start from.

    If you’re using emacs or any other text editor designed for XML, it may highlight tags differently from the text within them. There are also plenty of free XML editors for Windows and many of them will handle syntax highlighting. This syntax highlighting can make it easier to edit the XML, but isn't necessary for success. If you would like to find a text editor that provides this feature, try searching Google for a free XML editor you like or contact the ECEn Web Team for our recommendations.

    Finding and Preventing Mistakes
    It is easy to write XML. However, everyone makes mistakes and it can be difficult to figure out which tag you forgot to close once your document gets long. Here are some tips that the ECEn Web Team uses to help them write error-free XML and fix problems when they pop up.

    Keeping your XML Straight
    1
    Standardize the way your write your XML. Be consistent with when you create new lines and try to indent nested tags. There is no right way to write XML, as long as it is easy for you to keep track of it. If you view the XML for these pages by clicking on the ‘this XML’ in the footer of this document, you can see one way to clean up your XML. Some editors, like emacs, can manage the indentation for you.
    2
    Start looking at your page online as soon as you have a bit of the XML written and look at it periodically as you go along. That way, you have some idea of where you might be missing a closing tag when you discover an error in your XML.

    Finding Problems when They Happen
    If you have run into troubles with your page, have a look at the Troubleshooting Guide to understand exactly what the XML parse error means and what you can do about it. Not all XML parse errors have to do with missing closing tags.

    If you do discover you are missing a closing tag,
    1
    Use the line numbers in the XML parse error and look for problems around those line numbers.
    2
    Try commenting out parts of the XML code that you think might be the problem. Surround the perceived offending XML in <!--and --> tags, then look at your page online. If the parse error has gone away, there is a good chance that the problem is within the comment block. Just be careful that you leave a valid chuck of XML uncommented, or the page will parse error.
    3
    If you are using includes in your XML, be aware that errors in the included XML file will not cause the XML that included the file to parse error. The included XML will simply not show up in your final web page. For more information, have a look at the Troubleshooting Guide.
    4
    If you're still stuck (or just don't have the time or inclination to debug), contact the ECEn Web Team. We're happy to help.

    Maintained by The ECEn Web Team. Based on v. 3.8 of the ECEn web templates (view XML, live XML, see other formats).
    Copyright © 1994-2005. Brigham Young University. All Rights Reserved.