Search code examples
aemquery-builderjcr

Querying An XML File in AEM JCR


In SQL, I can query XML values based on xpath location within the XML. Is it possible to query text within an XML file in the JCR, based on xpath location in a similar fashion?

For example, I have an XML file (nt:resource) outputted from a workflow stored in the AEM JCR and would like to query the value of the price. If possible, what would the XPATH/SQL query look like to query the value from the XML below, assuming the location is, say, /var/fd/server/payload/file.xml?

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description>
   </book>

Solution

  • AEM Query builder is for JCR nodes, not for raw files. You will have to read the file via code, and then use xpath there for getting the values you need.