A number of student project files have been uploaded as collections to our eXist-dB XML database on newtfire. We will be working with some of these collections in this series of exercises.Go to the newtfire eXist in a web browser, and click on the eXide button to bring up a window to open files and write XQuery. This is also a review or orientation to XPath, so you should read and study the XPath Tutorial as you proceed.
/db/smashtiers/supersmashtierlist.xml
.doc('/db/smashtiers/supersmashtierlist.xml')//*
stepping downthe XML document hierarchy from the root to the descendant branches. Notice that the expression you just pasted in returns the entire document. That is because we are using the descendant axis to access the wildcard indicator:
*
, which includes any and all elements on the tree. Change that wildcard to select a specific element to look at all of the <char>
elements in the tree. Press Eval to see the results, and notice that the total number of results flashes briefly in the bottom right. You can page through the results using the arrow keys in the results window.char
elements only if are in game number 3. That is, the char
element must contain a child game
element with an @n
value of "3"
. In your text file, record your predicate expression, or record what you tried and note how many results you retrieve.char
elements to return a shorter list of results (those in game 2), you can also step down from those results to return other kinds of information, like the value of the attribute @id
on char
. To return attribute values in XQuery is a little tricky, however. You will see a number of results returned, but no actual values if you just step down to the attribute node. Follow this with ! string()
or ! data()
to view the attribute values. Record your expression and the number of results.
When you have completed the assignment copy and paste your expressions into a text file. Upload your text file containing your XPath and XQuery expressions to Canvas.