在w3c.org.dom.document中有对应的方法

解决方案 »

  1.   

    我没找到:(
    哪个啊!
    有个getElementsByTagNameNS
    也不象
      

  2.   

    如果该xml使用了DTD并且在DTD中指定id的类型为ID则可使用:
    doc.getElementById("100")
    否则:
    遍历所有element结点——对每个结点使用getAttribute("id")返回值不为null且等于100。
      

  3.   

    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写好了,就容易的多
      

  4.   

    XPath方法需要特定解析器的支持,标准DOM并无此定义啊。
      

  5.   

    getElementsByTagName()先用这个得到NODELIST,然后再用JAVA判断,我通常就是这样做的