You need something along the lines of this:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(<uri_as_string>);
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile(<xpath_expression>);
Then you call expr.evaluate()
passing in the document defined in that code and the return type you are expecting, and cast the result to the object type of the result.
If you need help with a specific XPath expressions, you should probably ask it as separate questions (unless that was your question in the first place here - I understood your question to be how to use the API in Java).
Edit: (Response to comment): This XPath expression will get you the text of the first URL element under PowerBuilder:
/howto/topic[@name='PowerBuilder']/url/text()
This will get you the second:
/howto/topic[@name='PowerBuilder']/url[2]/text()
You get that with this code:
expr.evaluate(doc, XPathConstants.STRING);
If you don't know how many URLs are in a given node, then you should rather do something like this:
XPathExpression expr = xpath.compile("/howto/topic[@name='PowerBuilder']/url");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
And then loop over the NodeList.
As an alternative to using a variable, you can make use of the "current()" operator to get the current Author node you are on
<xsl:value-of select="../Affiliation[@AFFID=current()/@AffiliationID]/OrgName"/>
Thus, if you take the following stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<AUG>
<xsl:for-each select="AuthorGroup/Author">
<AU>
<NAME>
<xsl:value-of select="./FamilyName"/>
<xsl:value-of select="./GivenName"/>
</NAME>
<AUINFO>
<xsl:value-of select="../Affiliation[@AFFID=current()/@AffiliationID]/OrgName"/>
</AUINFO>
</AU>
</xsl:for-each>
</AUG>
</xsl:template>
</xsl:stylesheet>
And apply it your given XML, the results should be like so
<AUG>
<AU>
<NAME>SmithJohn</NAME>
<AUINFO>Some Org</AUINFO>
</AU>
<AU>
<NAME>AtkinsBill</NAME>
<AUINFO>Another Org</AUINFO>
</AU>
</AUG>
Best Answer
You can go "up" a level using "
..
". So: