XPath Query with XML Tools on Atom

This section provides a tutorial example on how to use XML Tools package in Atom to run XPath query on any XML documents.

As described in the previous tutorial, "XML Tools" package on Atom offers 3 commands: Pretty-print format, Compress white spaces, and XPath query.

The first 2 commands are not that important. But the last command is important if you are developing XPath expressions to be used in your XSLT templates or other applications. You can open any input XML document and run queries to validate your XPath expressions interactively.

1. Open XML document, dictionary.xml, in Atom:

<?xml version="1.1"?>
<!-- dictionary.xml
 - Copyright (c) HerongYang.com. All Rights Reserved.
-->
<dictionary>
 <word acronym="true">
  <name>XML</name>
  <definition reference="Herong&apos;s Notes">eXtensible Markup 
Language.</definition>
  <update date="2022-12-23"/>
 </word>
 <word symbol="true">
  <name>&lt;</name>
  <definition>Mathematical symbol representing the "less than" logical 
operation, like: 1&lt;2.</definition>
  <definition>Reserved symbol in XML to representing the beginning of 
tags, like: <![CDATA[<p>Hello world!</p>]]>
  </definition>
 </word>
</dictionary>

2. Click "Packages > XML Tools > Query Document". The XPath query box shows up.

3. Enter XPath expression "//@date". 1 matched attribute found as I expected. Remember that default context assumes that the root element is the current node.

4. Enter XPath expression "//word[@symbol='true']". 1 matched element found as I expected.

5. Enter XPath expression "//definition". 3 matched elements found as I expected.

6. Enter XPath expression "//definition[1]". 2 matched elements found as I expected.

7. Enter XPath expression "//*[name()='word']". 2 matched elements found as I expected.

Cool. Now I have a nice tool to validate any XPath expression against any XML document.

XPath Query with XML Tools in Atom
XPath Query with XML Tools in Atom

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 XML-JSON Document Conversion

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 PHP Extensions for XML Manipulation

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

XML Plugin Packages for Atom Editor

 XML Tools Package for Atom

XPath Query with XML Tools on Atom

 atom-xsltransform Package for Atom

 XML 1.1 Changes and Parsing Examples

 Outdated Tutorials

 References

 Full Version in PDF/EPUB