I'm just getting started on learning XPath and the subset XQuery in order to query and parse an XML document(s) set much like a SQL database.
My first question is how do you -easily- return more than one related element for a specific query?
For instance, here's a sample XPath query of mine:
doc(XXXfakeURL.xml?user=username;pwd=mypassword)//schedule[employee-id=1425 and activity-id=2058]/time-start
This opens a certain XML document, finds the schedule element with a certain employee and activity, and returns the element "time-start."
However, what if I want to return MULTIPLE child elements from that node? Like, not only time-start, but also time-end, work group, other stuff, blah blah, etc. I don't want to type that whole path again.
For now, I've discovered I could do [verbose query]/node()[position()=4 or position=(7)].
This, through some probably non-ideal code, returns the nodes at multiple positions, which I have to look up, instead of simply returning multiple elements.
My other question is if I can store URL names in variables in XML.
Like say I frequently reference doc("locolhost:8888/schedule/1032/employees/3230/planninggroup/2014.xml?user=johnsmith&pwd=mysecretpassword")
Is there a way to store that document in a variable? Or at least make it shorter?
I think this application I'm querying (3rd party application) may have literally hundreds of XML documents that comprise the "data" so I may not even be able to re-use one document URL. My code just seems super cluttered because I have to call a HUGE URL document for an employee list, another giant URL document for schedules, ANOTHER to determine what office everyone works at ---- why this wasn't put in just one document, I'm not sure.