Here you can find the source of getSiblingValues(Node currentNode, Set
Parameter | Description |
---|---|
currentNode | a parameter |
siblingTags | a Set of Strings containing the tagnames to look for |
public static Map<String, String> getSiblingValues(Node currentNode, Set<String> siblingTags)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import java.util.Set; import org.w3c.dom.Node; public class Main { /**//ww w. ja v a2s.c o m * This method looks at the siblings of a given node, matches the ones in the passed Set, * then returns a map of the matches with their values * * @param currentNode * @param siblingTags a Set of Strings containing the tagnames to look for * @return Map of desired tag names to their values */ public static Map<String, String> getSiblingValues(Node currentNode, Set<String> siblingTags) { Map<String, String> responseMap = new HashMap<String, String>(); String testString = currentNode.getLocalName().toLowerCase(); for (String tagName : siblingTags) { if (testString.contains(tagName.toLowerCase())) { responseMap.put(tagName, currentNode.getTextContent() .trim()); return responseMap; } } return responseMap; } }