Translation

The oldest posts, are written in Italian. If you are interested and you want read the post in English, please use Google Translator. You can find it on the right side. If the translation is wrong, please email me: I'll try to translate for you.

lunedì, agosto 28, 2017

Using XML 03: Introduction, Part 3/3

In this post I continue the introduction of an XML document.

XML Namespaces

XML Namespaces provide a method to avoid element name conflicts.

Please, see [1]: they explain in really simple way what the "XML Namespace are.


XML and XPath [2][3]

The XPath language is based on a tree representation of the XML document, and provides the ability to navigate around the tree, selecting nodes by a variety of criteria. It is used to navigate through elements and attributes.

Based on the previosu XML document, you can generalyze it as follow:


XML documents have a hierarchical structure and can conceptually be interpreted as a tree structure, called an XML tree.

XML documents must contain a root element (one that is the parent of all other elements). All elements in an XML document can contain sub elements, text and attributes. The tree represented by an XML document starts at the root element and branches to the lowest level of elements.

XPath defines a syntax named XPath expressions that identifies one or more internal components (elements, attributes, etc.) of an XML document. In popular use (though not in the official specification), an XPath expression is often referred to simply as "an XPath".


Syntax and semantics (XPath 1.0) [2]

The most important kind of expression in XPath is a location path. A location path consists of a sequence of location steps. Each location step has three components:


  • An axis. An "axis" specifiers indicate navigation direction within the tree representation of the XML document. The axes available are

https://en.wikipedia.org/wiki/XPath#Axis_specifiers



  • A node test

https://en.wikipedia.org/wiki/XPath#Node_tests



  • Zero or more predicates.

https://en.wikipedia.org/wiki/XPath#Predicates

In the table below we have listed some XPath expressions and the result of the expressions:





References

[1] https://www.w3schools.com/xml/xml_namespaces.asp
[2] https://en.wikipedia.org/wiki/XPath
[3] https://www.w3schools.com/xml/xml_xpath.asp
[4] https://en.m.wikipedia.org/wiki/XML_tree

Nessun commento: