用于命名空间元素的W3C
dom方法:
getElementsByTagNameNSNodeList getElementsByTagNameNS(String namespaceURI, String localName) Returns a NodeList of all the Elements with a given local name and namespace URI in document order. Parameters: namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces. localName - The local name of the elements to match on. The special value "*" matches all local names. Returns: A new NodeList object containing all the matched Elements. Since: DOM Level 2
IIRC的W3C
DOM早期版本对名称空间的支持较差,因此我不使用它。但是,如果将上述内容与完整的namespaceURI结合使用,则
http://schemas.xmlsoap.org/soap/envelope/它应该可以工作。前缀是不重要的-
在使用它的文档之外没有永久性。
所以尝试:
System.out.println("Element :" + doc.getElementsByTagNameNS( "http://schemas.xmlsoap.org/soap/envelope/", "Token").item(0));


