How to Create a Simple XML File

XML files are written in order to store information in a hierarchical fashion for later querying either by a database or information retrieval system. One of the greatest attractions of XML is that it is extremely flexible and can be molded by the system designer. For example, the tags are not predetermined as they are in HTML. The designer can label the tags however they see fit according to the nature of the task at hand. Although XML offers flexibility there are certain guidelines that must be followed in order for programs to run efficiently and logically. This article demonstrates how to create a single student entry for a grade book in XML.

Things You'll Need

  • Text editor (Preferably ConText)
  • XML editor (optional)
Show More

Instructions

    • 1

      Create the declaration. Open a page in your text editor and type the following:
      <?xml version=1.0?>
      This is simply a declaration of what version of xml is being used. If you are using a later version you can write that in instead.

    • 2

      Create the mother node. This is a broad description of the data. In this example the mother node will be called <gradebook>. So far the document should look like this:
      <?xml version=1.0?>
      <gradebook>
      </gradebook>
      Notice that you must close the tag with a '/' symbol.

    • 3

      Create the root element. Our root element will be the student, <student>. The root element goes between the opening and closing tags of the mother node.
      <?xml version=1.0?>
      <gradebook>
      <student>
      </student>
      </gradebook>

    • 4

      Create nested elements and input information. Since the grade book keeps track of students' grades, add nested elements for the 'student name','the date of the test', 'the type of test', and 'the grade'. Input the appropriate information between each tag. The document should read as follows:
      <?xml version=1.0?>
      <gradebook>
      <student>
      <name>John Smith</name>
      <date>March 1 2009</date>
      <type>Oral exam</type>
      <grade>95</grade>
      </student>
      </gradebook>

    • 5

      Save the document. Go to 'save as' and save the document as "grades.xml". That's it. You have created a basic XML document. Now it is ready to be parsed by another program written in a more powerful language such as PERL or ASP.

Tips & Warnings

  • The declaration isn't necessary for all programs.

  • You are probably thinking that XML would be very monotonous to write, just the same old tags over and over again... However, the output should be done through an input interface that automatically prints out the tags as the information is saved. XML's utility is enhanced when it is utilized for other data driven programs.

  • Don't wait for XML to do anything. It is just a language used to organize data to be utilized by other programs. It is an excellent for this purpose but doesn't really do much of anything else.

  • Make sure to close your tags.

  • Make sure to write all in lower or upper case. Never use a mixture of both.

Related Searches:

References

  • Goldberg,K.H.(2009).Visual Quickstart Guide: XML. Berkeley:Peachpit Press

Comments

You May Also Like

  • How to Create XML From an iSeries File

    iSeries refers to the AS/400 business management tool that keeps data for all your branches of business. While AS/400 is a popular...

  • How to Create an .Xml File

    XML stands for Extensible Markup Language. This form of computer programming transports and stores data as a text file but does not...

  • How to Create XSL From an XML File

    XSL is a stylesheet language used to format elements created in XML. Therefore, XSL is typically written by hand using a stylesheet...

  • How to Create an XML File With Javascript

    XML has come to be regarded as an important base on which Web Services work. Businesses can work together upon agreed standards...

  • How to Load an XML File With PHP

    "Extensible Markup Language," or XML, is a commonly used method of storing information in a highly structured way that's easy for computers...

  • How to Write Into XML File Using PHP

    XML is a Web design standard that uses HTML to order data. For some programmers, the ability to print out XML files...

  • How to Create a New XML File

    New XML files are generated by programs as a way of housing output data for later querying by the same or a...

  • How to Convert an XML File to a PHP File

    XML (eXtensible Markup Language) is a convenient way of writing human-readable data sets which can also be shared between computer systems that...

  • How to Convert PDF Files to XML

    Extensible Markup Language (XML) is a text-based language designed to store and carry data, and is commonly used in website and database...

  • How to Create an XML File from an SQL Database

    You can use Hypertext Markup Language (HTML) and Cascading Style Sheets (CSS) to bind and format XML data on your web page...

  • How to Create an XML File From ASP

    Extensible Markup Language (XML) is a language used to hold records in recognizable tags similar to HTML. You can use the C#...

  • How to Create a Web Page Using XML

    XML, which stands for Extensible Markup Language, is the international standard (ISO) for data representation on the web. The primary difference between...

  • XML Spy Tutorial

    XML Spy is an XML editor made by Altova. The program assists developers in creating XML-related applications and debugging, editing, transforming and...

  • How to Create XML From Database Using Visual Basic

    One of the responsibilities of Web designers and technical writers is having the ability to retrieve information from a database. Visual Basic,...

  • How to Edit an XML File in PHP

    Use PHP (Hypertext Preprocessor) to manage, edit and control other files of different formats on your server. Extensible Markup Language (XML) is...

Related Ads

Featured