How to Add an XML Attribute

The use of XML on the Internet is becoming ubiquitous. From storing local application information to sending large amounts of data around the world, XML can be found everywhere. One of its great strengths is the ability to add structure to one dimensional data. XML Attributes provide a way to add descriptive values to the data represented in the text. XML Attributes reside in the opening tag of the element they describe. It can be any element in the document. Their form is a "name=value" pair with the value enclosed in quotes.

Instructions

  1. Create the Document

    • 1

      Create an XML document using either an XML editor or a simple text editor, like Notepad.

    • 2

      Click "File", then "New" to create a new file if you are using Notepad.

    • 3

      Click "File" next, then "Save As."

    • 4

      Select "All files" from the "Save as type" drop-down menu in the "Save As" dialog box.

    • 5

      Name your file using a ".XML" file extension and click "OK" to exit.

    Add an XML Attribute

    • 6

      Add the required XML document tag to your file. For example:

    • 7

      Add the root element and closing tag to your document. For example, here is an element named "root":



    • 8

      Add an Attribute to the root element. For example, the XML Attribute 'version="first"' is added:


Tips & Warnings

  • Use an XML editor to help speed development time and reduce errors.

  • Validate your XML documents before deployment to the Internet.

Related Searches:

Comments

You May Also Like

Related Ads

Featured