XPath Query Tools – XmlToolBox


Lately I have been working more and more with Extended Events and prior to that Cached Plans exploration.

And, has both are stored as XML, it makes sense to see what tools are available for accurately querying XML data.



Here is the collected event.

<event name="sql_batch_completed" package="sqlserver" timestamp="2017-05-01T16:44:02.507Z">
  <data name="cpu_time">
  <data name="duration">
  <data name="physical_reads">
  <data name="logical_reads">
  <data name="writes">
  <data name="row_count">
  <data name="result">
  <data name="batch_text">
    <value>SELECT "dbo"."basetblb"."base_social" FROM "dbo"."basetblb" WHERE (("base_payroll_status" = 'A' ) AND ("base_service_credit" &gt; 10 ) ) </value>
  <action name="sql_text" package="sqlserver">
    <value>SELECT "dbo"."basetblb"."base_social" FROM "dbo"."basetblb" WHERE (("base_payroll_status" = 'A' ) AND ("base_service_credit" &gt; 10 ) ) </value>
  <action name="session_server_principal_name" package="sqlserver">
  <action name="session_id" package="sqlserver">
  <action name="server_principal_name" package="sqlserver">
  <action name="server_instance_name" package="sqlserver">
  <action name="is_system" package="sqlserver">
  <action name="database_name" package="sqlserver">
  <action name="database_id" package="sqlserver">
  <action name="client_hostname" package="sqlserver">
  <action name="client_app_name" package="sqlserver">
    <value>Microsoft® Windows® Operating System</value>
  <action name="collect_system_time" package="package0">
  <action name="attach_activity_id_xfer" package="package0">
  <action name="attach_activity_id" package="package0">



Googled on XML Query XPath and found many tools.

In this post we will discuss XMLToolBox.



I liked XMLToolBox has unlike many other tools one does not have to start with a query, just paste the the XML body unto the canvas, and point at the XML element or attribute you want to generate the query on.


Here is the Link for XMLToolbox.


Here is what happens when we :

  1. Copy and paste the XML noted above unto the XML field textarea
  2. Find the result element and click on the text element


Here is the generated Xpath:




  1. Parse using event ( /event )
  2. Look for the attribute name matching sql_batch_completed
  3. Transverse to the 7th data element
  4. Find the text element within the the 7th element and return the text portion of that element



XMLToolBox is easy to use and capable.

Unfortunately, it lacks flexibility because it is based on the position of elements.

If the schema changes a bit, the XPath might return the wrong element as it would refer to the original position.


One thought on “XPath Query Tools – XmlToolBox

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s