Coding With Fun
Home Docker Django Node.js Articles FAQ

XLink and XPointer syntax

May 28, 2021 XLink

Table of contents

XLink and XPointer syntax

What are the syntax formats for XLink and XPointer when using them? The answer is in this section.

XLink syntax

In HTML, we know that the elements can define hyperlinks. B ut XML doesn't work that way. In an XML document, you can use whatever name you want - so it's impossible for a browser to predict what hyperlink elements can be called in an XML document.

The way to define hyperlinks in an XML document is to place tags on elements that can be used as hyperlinks.

Here's a simple example of using XLink to create a link in an XML document:

<?xml version="1.0"?>
<homepages xmlns:xlink="">

<homepage xlink:type="simple"
xlink:href="" rel="external nofollow" target="_blank" >Visit W3Cschools</homepage>

<homepage xlink:type="simple"
xlink:href="" rel="external nofollow" target="_blank" >Visit W3C</homepage>


In order to access the properties and attributes of XLink, we must declare the XLink namespace at the top of the document.

XLink's namespace is"

The xlink:type and xlink:href properties in the element define the type and href properties from the XLink namespace.

xlink:type"simple" creates a simple link between the ends (meaning "where to go from here"). We'll look at multi-end links (multi-directional) later.

XPointer syntax

In HTML, we can create a hyperlink that points to both an HTML page and a bookmark within the HTML page (using .

Sometimes it's better to point to more specific content. F or example, we need to point to the third item of a particular list, or to the second line of the fifth paragraph. XPointer is easy to do.

If the hyperlink points to an XML document, we can add the XPointer section to the Xlink:href property after the URL so that we can navigate (through the XPath expression) to a specific location in the document.

For example, in the following example, we use XPointer to point to the fifth item in a list with the unique id "rock".

href="'rock').child(5,item)" rel="external nofollow" target="_blank"

Related tutorials

HTML tutorial