Skip to content
XML

Attributes

Name-value pairs on elements.

By EZ4Code Team
attributeelement

Code

<?xml version="1.0"?>
<contact id="c100" active="true">
  <name lang="en" type="full">Alice Smith</name>
  <phone type="mobile" primary="true">+1-555-0100</phone>
  <phone type="home">+1-555-0199</phone>
  <note priority='high'>Values must be quoted with single or double quotes</note>
</contact>

Explanation

XML attributes are name-value pairs that appear inside an element's opening tag and must always be quoted. An element cannot have two attributes with the same name, even when namespaced differently. Use attributes for metadata and child elements for data that needs structure or repetition.

More XML Snippets