XML Elements vs Attributes
Different between XML element and attribute important to know because XML elements and attributes both way you can represent same things.
<emp_info id="1"> <!-- Attributes represent-->
...
<emp_info>
<emp_info> <!-- Elements represent-->
<id>1</id>
<emp_info>
Definition Attributed are the part of the markup (for identifiers of elements). Where as the element are part of the document to store data.
Distinction Attributed specify when identifier of elements. And element specify contains for storing data.
XML Elements
Every document must have a one top level element called root element.
XML element contents are part of the basic document contents. that are store information data.
XML elements are represented by a tags.
XML Element Name must be follow this things
Element names must be alphabetic or numeric character contains.
Element name can't have white spaces contains and
name can't start with capital letter, numeric or mixed letter.
If element contents absence(empty) then you can write element following two way to represent valid standard.
<element />
<element></element>
XML Attributes
XML element can have attributes for identify elements.
<emp_info id="1"> <!-- Attributes represent-->
<name>
<first_name>Opal</first_name>
<middle_name>Venue</middle_name>
<last_name>Kole</last_name>
</name>
<emp_info>
XML attributes specified by name="value" pair inside the starting element. XML attribute values must be quoted.
XML standard specifies element may have define multiple attributes along with unique attribute name.
<emp_info id="1" name="Opal Kole"> <!-- Attributes represent-->
...
<emp_info>