public class DOMParserUtil extends Object
Modifier and Type | Method and Description |
---|---|
protected static Stream<Node> |
asStream(NodeList nodeList)
Return a
Stream out of the given NodeList . |
static void |
cleanupNodes(Document document,
String containerNodeName,
String nodeToRemoveName)
This method remove the nodeToRemoveName
Node s from all the containerNodeName Elements found inside the given fullXml |
static String |
cleanupNodes(String fullXml,
String containerNodeName,
String nodeToRemoveName)
This method remove the nodeToRemoveName
Node s from all the containerNodeName Elements found inside the given fullXml |
static Map<Node,Node> |
createNestedNodes(Document document,
String mainContainerNodeName,
String containerNodeName,
String childNodeName,
String nodeContent)
Create childNodeName nodes in all containerNodeNames presents in all mainContainerNodes of the document
|
static Node |
createNodeAtPosition(Node containerNode,
String nodeToCreateName,
String nodeContent,
Integer position)
Create a nodeToCreateName
Node inside containerNode. |
static Map<Node,Node> |
createNodes(Document document,
String containerNodeName,
String childNodeName,
String nodeContent)
Create childNodeName nodes in all containerNodeName presents in the document
|
static String |
getAttributeValue(Node containerNode,
String attributeName) |
static Map<Node,String> |
getAttributeValues(Document document,
String attributeName)
Return a
Map where the key is any Node inside the given document
and the value is the node value of the attribute with the given attributeName
It returns an empty map no Node contains such attribute |
static Map<Node,String> |
getAttributeValues(Document document,
String containerNodeName,
String attributeName)
Return a
Map where the key is the Node with the given containerNodeName
and the value is the node value of the attribute with the given attributeName
It returns an empty map if such attribute does not exists |
static List<Node> |
getChildrenNodesList(Node node,
String childNodeName) |
static Map<Node,List<Node>> |
getChildrenNodesMap(Document document,
String containerNodeName,
String childNodeName)
Get all childNodeName nodes in all containerNodeNames presents in document
|
static Map<Node,List<Node>> |
getChildrenNodesMap(Node node,
String containerNodeName,
String childNodeName) |
static Map<Node,List<Node>> |
getChildrenNodesMap(String fullXml,
String containerNodeName,
String childNodeName)
Get all childNodeName nodes in all containerNodeNames presents in fullXml
|
static Document |
getDocument(String xml) |
static List<Node> |
getNestedChildrenNodesList(Document document,
String grandParentNodeName,
String parentNodeName,
String childNodeName) |
static List<Node> |
getNestedChildrenNodesList(Node node,
String containerName,
String childNodeName) |
static Map<Node,List<Node>> |
getNestedChildrenNodesMap(Document document,
String mainContainerNodeName,
String containerNodeName,
String childNodeName)
Get all childNodeName nodes in all containerNodeNames presents in all mainContainerNodeNames of the document
|
static String |
getString(Document toRead) |
protected static void |
populateAttributeValuesMap(Node node,
String attributeName,
Map<Node,String> toPopulate)
Recursively populate the given
Map |
static String |
replaceNodeName(Document document,
String containerNodeName,
String childNodeNameToReplace,
String childNodeNameReplacement)
Replace all childNodeNameToReplace nodes in all containerNodeNames presents in document with childNodeNameReplacement
|
static void |
replaceNodeText(Document document,
String containerNodeName,
String nodeName,
String toReplace,
String replacement)
Replace the text content of the given nodeName inside the given
containerNodeName . |
static void |
setAttributeValue(Document document,
String containerNodeName,
String attributeName,
String attributeValue) |
public static String cleanupNodes(String fullXml, String containerNodeName, String nodeToRemoveName) throws Exception
Node
s from all the containerNodeName Elements found inside the given fullXmlfullXml
- containerNodeName
- nodeToRemoveName
- Exception
public static void cleanupNodes(Document document, String containerNodeName, String nodeToRemoveName)
Node
s from all the containerNodeName Elements found inside the given fullXmldocument
- containerNodeName
- nodeToRemoveName
- public static void replaceNodeText(Document document, String containerNodeName, String nodeName, String toReplace, String replacement)
containerNodeName
.
The replace happen only if the given nodeName text is equals to toReplacedocument
- containerNodeName
- nodeName
- toReplace
- replacement
- public static String replaceNodeName(Document document, String containerNodeName, String childNodeNameToReplace, String childNodeNameReplacement) throws Exception
document
- containerNodeName
- childNodeNameToReplace
- childNodeNameReplacement
- Exception
public static Map<Node,String> getAttributeValues(Document document, String containerNodeName, String attributeName)
Map
where the key
is the Node
with the given containerNodeName
and the value is the node value of the attribute with the given attributeName
It returns an empty map if such attribute does not existsdocument
- containerNodeName
- attributeName
- public static Map<Node,String> getAttributeValues(Document document, String attributeName)
Map
where the key
is any Node
inside the given document
and the value is the node value of the attribute with the given attributeName
It returns an empty map no Node
contains such attribute
document
- attributeName
- public static void setAttributeValue(Document document, String containerNodeName, String attributeName, String attributeValue)
public static Map<Node,Node> createNodes(Document document, String containerNodeName, String childNodeName, String nodeContent)
document
- containerNodeName
- childNodeName
- nodeContent
- public static Map<Node,Node> createNestedNodes(Document document, String mainContainerNodeName, String containerNodeName, String childNodeName, String nodeContent)
document
- containerNodeName
- childNodeName
- nodeContent
- public static Node createNodeAtPosition(Node containerNode, String nodeToCreateName, String nodeContent, Integer position)
Node
inside containerNode.
If nodeContent is not null, add it as text content.
If position is not null, put the created node at position 0containerNode
- nodeToCreateName
- nodeContent
- position
- public static Map<Node,List<Node>> getChildrenNodesMap(String fullXml, String containerNodeName, String childNodeName) throws Exception
fullXml
- containerNodeName
- childNodeName
- Exception
public static Map<Node,List<Node>> getChildrenNodesMap(Document document, String containerNodeName, String childNodeName)
document
- containerNodeName
- childNodeName
- public static Map<Node,List<Node>> getChildrenNodesMap(Node node, String containerNodeName, String childNodeName)
public static Map<Node,List<Node>> getNestedChildrenNodesMap(Document document, String mainContainerNodeName, String containerNodeName, String childNodeName)
document
- mainContainerNodeName
- containerNodeName
- childNodeName
- public static List<Node> getNestedChildrenNodesList(Document document, String grandParentNodeName, String parentNodeName, String childNodeName)
public static List<Node> getNestedChildrenNodesList(Node node, String containerName, String childNodeName)
public static Document getDocument(String xml) throws ParserConfigurationException, IOException, SAXException
protected static void populateAttributeValuesMap(Node node, String attributeName, Map<Node,String> toPopulate)
Map
node
- attributeName
- toPopulate
- Copyright © 2001–2019 JBoss by Red Hat. All rights reserved.