类 DomUtils
java.lang.Object
com.walker.infrastructure.utils.DomUtils
Convenience methods for working with the DOM API, in particular for working with DOM Nodes and DOM Elements.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static ContentHandlercreateContentHandler(Node node) Returns a SAXContentHandlerthat transforms callback calls to DOMNodes.static ElementgetChildElementByTagName(Element ele, String childEleName) Utility method that returns the first child element identified by its name.getChildElements(Element ele) Retrieve all child elements of the given DOM elementgetChildElementsByTagName(Element ele, String childEleName) Retrieve all child elements of the given DOM element that match the given element name.getChildElementsByTagName(Element ele, String[] childEleNames) Retrieve all child elements of the given DOM element that match any of the given element names.static StringgetChildElementValueByTagName(Element ele, String childEleName) Utility method that returns the first child element value identified by its name.static StringgetTextValue(Element valueEle) Extract the text value from the given DOM element, ignoring XML comments.static booleannodeNameEquals(Node node, String desiredName) Namespace-aware equals comparison.
-
构造器详细资料
-
DomUtils
public DomUtils()
-
-
方法详细资料
-
getChildElementsByTagName
Retrieve all child elements of the given DOM element that match any of the given element names. Only look at the direct child level of the given element; do not go into further depth (in contrast to the DOM API'sgetElementsByTagNamemethod).- 参数:
ele- the DOM element to analyzechildEleNames- the child element names to look for- 返回:
- a List of child
org.w3c.dom.Elementinstances - 另请参阅:
-
getChildElementsByTagName
Retrieve all child elements of the given DOM element that match the given element name. Only look at the direct child level of the given element; do not go into further depth (in contrast to the DOM API'sgetElementsByTagNamemethod).- 参数:
ele- the DOM element to analyzechildEleName- the child element name to look for- 返回:
- a List of child
org.w3c.dom.Elementinstances - 另请参阅:
-
getChildElementByTagName
Utility method that returns the first child element identified by its name.- 参数:
ele- the DOM element to analyzechildEleName- the child element name to look for- 返回:
- the
org.w3c.dom.Elementinstance, ornullif none found
-
getChildElementValueByTagName
Utility method that returns the first child element value identified by its name.- 参数:
ele- the DOM element to analyzechildEleName- the child element name to look for- 返回:
- the extracted text value, or
nullif no child element found
-
getChildElements
Retrieve all child elements of the given DOM element- 参数:
ele- the DOM element to analyze- 返回:
- a List of child
org.w3c.dom.Elementinstances
-
getTextValue
Extract the text value from the given DOM element, ignoring XML comments.Appends all CharacterData nodes and EntityReference nodes into a single String value, excluding Comment nodes.
-
nodeNameEquals
Namespace-aware equals comparison. Returnstrueif eitherNode.getLocalName()orNode.getNodeName()equalsdesiredName, otherwise returnsfalse. -
createContentHandler
Returns a SAXContentHandlerthat transforms callback calls to DOMNodes.- 参数:
node- the node to publish events to- 返回:
- the content handler
-