package org.apache.xpath;public class XPathAPI { public static Node selectSingleNode(Node context, String xpath) throws TransformerException; public static Node selectSingleNode(Node context, String xpath, Node namespaceContextNode) throws TransformerException; public static NodeIterator selectNodeIterator(Node context, String xpath) throws TransformerException; public static NodeIterator selectNodeIterator(Node context, String xpath, Node namespaceContextNode) throws TransformerException; public static NodeList selectNodeList(Node context, String xpath) throws TransformerException; public static NodeList selectNodeList(Node context, String xpath, Node namespaceContextNode) throws TransformerException; public static XObject eval(Node context, String xpath) throws TransformerException; public static XObject eval(Node context, String xpath, Node namespaceContextNode) throws TransformerException; public static XObject eval(Node context, String xpath, PrefixResolver prefixResolver) throws TransformerException;
}Each method in this class takes two or three arguments: The context node as a DOM Node objectThe XPath expression as a StringThe namespace prefix mappings as a DOM Node object or a Xalan PrefixResolver object. This can be omitted if the XPath expression does not use any namespace prefixes.没用过,不敢妄言,不过我想只要XPath写好了,就容易的多
哪个啊!
有个getElementsByTagNameNS
也不象
doc.getElementById("100")
否则:
遍历所有element结点——对每个结点使用getAttribute("id")返回值不为null且等于100。
throws TransformerException;
public static Node selectSingleNode(Node context, String xpath,
Node namespaceContextNode) throws TransformerException;
public static NodeIterator selectNodeIterator(Node context,
String xpath) throws TransformerException;
public static NodeIterator selectNodeIterator(Node context,
String xpath, Node namespaceContextNode)
throws TransformerException;
public static NodeList selectNodeList(Node context,
String xpath) throws TransformerException;
public static NodeList selectNodeList(Node context,
String xpath, Node namespaceContextNode)
throws TransformerException;
public static XObject eval(Node context, String xpath)
throws TransformerException;
public static XObject eval(Node context, String xpath,
Node namespaceContextNode) throws TransformerException;
public static XObject eval(Node context, String xpath,
PrefixResolver prefixResolver) throws TransformerException;
}Each method in this class takes two or three arguments: The context node as a DOM Node objectThe XPath expression as a StringThe namespace prefix mappings as a DOM Node object or a Xalan PrefixResolver object. This can be omitted if the XPath expression does not use any namespace prefixes.没用过,不敢妄言,不过我想只要XPath写好了,就容易的多