What is the difference between "node", "attribute", "element" and "tag" in XML?

8

I'm confused about some features and terms of the XML markup language that are: node , attribute > element and tag tags , I would like to know what each one is and what are the differences between them?

Follow this XML to help explain and serve as an example:

<alunos>
    <aluno>
        <nome>Dener</nome>
        <nota1>7</nota1>
        <nota2>8</nota2>
        <nota3>5</nota3>
        <nota4>10</nota4>
    </aluno>

    <aluno>
        <nome>Raphael</nome>
        <nota1>8</nota1>
        <nota2>6</nota2>
        <nota3>6</nota3>
        <nota4>9</nota4>
    </aluno>

    <aluno>
        <nome>Ana</nome>
        <nota1>5</nota1>
        <nota2>6</nota2>
        <nota3>4</nota3>
        <nota4>5</nota4>
    </aluno>
</alunos>
    
asked by anonymous 14.08.2016 / 00:49

1 answer

11

Node or node is every bit of XML. Sets of nodes are forming other nodes. Comparing, roughly speaking, with programming language, are tokens . Some nodes have specific meaning and some of them are described below.

element element element is a complete block of data and markup that gives semantics to the given. It includes some of the nodes described below.

Tag or tag is the marking of what a given data means. It is always determined by a word within the <> sign. There may be a tag that opens the block and one that closes. Some are self-closing.

Some tags may have some specific information that gives the semantics of the data that is contained therein, they are called attribute or attribute . Normally it is a key pair (indicating what is being said there) and value (which informs the attribute), but there are only those that are key.

Text still exists within certain tags that are the data. From the point of view of XML is always a text. If the data is of any other kind deserves a conversion, it will be determined by tag and its attributes, or by a schema that determines this and an application can know how to interpret (very common).

Then

<nota1>7</nota1>

There is a given 7 that, of course, is a node. There are a couple of tags encapsulating this node giving the semantics that this is nota 1 . All this together forms another knot. This particular node is an element.

There are no attributes throughout the XML that appears in the question. But it could be, I do not know, something like this:

<nota1 prova=true>7</nota1>

prova=true is a tribute.

All this together is another node:

<aluno>
    <nome>Dener</nome>
    <nota1>7</nota1>
    <nota2>8</nota2>
    <nota3>5</nota3>
    <nota4>10</nota4>
</aluno>

All the XML presented in the question is another node.

It is common for people to have difficulty defining whether something must be an element or just an attribute of the element. It is necessary to understand what is a given (which is the fundamental part of an element) and what is just a "decoration" of the given (the attribute). This attribute is the same as HTML, after all XML is very similar. In a way we can say that HTML is a specialized XML, and specified to standardize the web.

schema is a way of indicating its structure, definition of the meaning of possible elements, constraints and other useful information for its understanding and manipulation.

    
14.08.2016 / 01:17