XML Processing with XPath

Demonstrates the usage of the XML nodes. It reads from an XML file describing books that were written by or about George W. Bush. The books are categorized. The workflow extracts all information such as ISBN, author, title, etc. and groups the books by category. The output file is (again) an xml file but in a different format (grouped by year).

This is a companion discussion topic for the original entry at https://kni.me/w/8CQmwMkEoBkTdaPA

Hi RS,

can you please tell me the meaning of @ sign.


you use @ sing for extracting year column from xml file

many thanks,

@ sign is used for numeric values
while when extracting string values we don’t need to use this symbol?
is it correct?

while grouping out put xml, you do not include author name?
is it intentionally exclude?

@ raomohsinkhan, you may already have found this out by now, but an @ sign in xpath indicates this is an attribute rather than an element

so if you have the following different xml snippets:

   <book author="George Orwell" title="Nineteen Eighty Four">

     <author>George Orwell</author>
     <title>Nineteen Eighty Four</title>

Then in the first snippet, author and title are attributes of <book> and you would reference them as

whereas in the second snippet, author and title are elements within <book> and you would reference them as

In the workflow, you can see that “year” is an attribute of <book> as it appears inside <book title=xxxx > whereas <author> and <title> are elements in their own right:

<?xml version="1.0" encoding="UTF-8"?>
<book year="2001">     <!-- year is an attribute -->
    <author>Vincent Bugliosi</author>
    <title>The Betrayal of America: How the Supreme Court Undermined the Constitution and Chose Our President</title>
    <category>About Elections</category>