XML


In the below example, we are going to see how to use xml response in grafana

image

<users>
    <user age="20">
        <name>User A</name>
    </user>
    <user age="21">
        <name>User B</name>
     </user>
</users>

In the above example XML, we want list the user's name and age. So use the below syntax

Rows/Root : users.user to select all the user objects inside user element

Columns:

Column1 Name : Use name as the selector for the property name

Column2 Age : Use $.age as the selector for the attribute age

Example 2#

Consider the below example

<users>
    <user age="20"> User A</user>
    <user age="21">User B</user>
    <user age="18">User C</user>
</users>

In the above example XML, we want list the user's name and age. So use the below syntax

Rows/Root : users.user to select all the user objects inside user element

Columns:

Column1 Name : Use _ as the selector for the property name. Here _ refers to the text inside the node

Column2 Age : Use $.age as the selector for the attribute age

Example 3#

Consider the below example

<users>
    <user>User A</user>
    <user>User B</user>
    <user>User C</user>
  </users>

In the above example XML, we want list the user's name. So use the below syntax

Rows/Root : users.user to select all the user objects inside user element

Columns:

Column1 Name : Use _ as the selector for the property name. Here _ refers to the text inside the node

XML URL#

You can also use the hosted XML via the URL. Example shown below demonstrates how we connect XML from this gist.

image

Sample example visualized using bar gauge panel and timeseries format.

image