Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
This
class provides methods to implement low-level XPath API. This is the best class
to be used for one time use. As most of the methods in this class are static so
you can use it by applying on the context node. In my application, most of the
time, I have used methods when I need to use XPath to instead of doing DOM
manipulation.
The
methods in this class are convenience methods into the low-level XPath API.
These functions tend to be a little slow, since a number of objects must be
created for each evaluation. A faster way is to precompile the XPaths using the
low-level API, and then just use the XPaths over and over. NOTE: In particular,
each call to this method will create a new XPathContext, a new DTMManager...
and thus a new DTM. That's very safe, since it guarantees that you're always
processing against a fully up-to-date view of your document. But it's also
portentially very expensive, since you're rebuilding the DTM every time. You
should consider using an instance of CachedXPathAPI rather than these static
methods.
Method Overviews
The
methods in this class are convenience methods into the low-level XPath API.
These functions tend to be a little slow, since a number of objects must be
created for each evaluation.
When
performance is a issue, then better to use precompile the XPaths using the
low-level API, and then just use the XPaths over and over.
NOTE:
In particular, each call to this method will create a new XPathContext, a new
DTMManager... and thus a new DTM. That's very safe, since it guarantees that
you're always processing against a fully up-to-date view of your document. But
it's also portentially very expensive, since you're rebuilding the DTM every
time. You should consider using an instance of CachedXPathAPI rather than these
static methods.
Example of selectNodeIterator(Node contextNode,
java.lang.String str)
selectNodeIterator()
is used to used to get a nodelist in the form of NodeIterator by applying an
XPath on contextNode.
NodeIterator iterator =
XPathAPI.selectNodeIterator(doc,"//person");//Instead of person you
can provide a string representation of XPath.
Example of selectNodeList(Node contextNode,
java.lang.String str)
selectNodeList()
is used to get a NodeList by applying XPath on the context node.
NodeIterator iterator = XPathAPI.selectNodeList(doc,"//person");//Instead
of person you can provide a string representation of XPath.