Changeset 37519
- Timestamp:
- 2023-03-16T19:54:02+13:00 (5 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
r37362 r37519 1159 1159 } 1160 1160 1161 public static Element findMatchingElement(Element root, String node_local_name, String[] attribute_names, String[] attribute_values) { 1162 if (attribute_names.length == 0 || attribute_names.length != attribute_values.length) 1163 { 1164 return null; 1165 } 1166 NodeList elems = root.getElementsByTagName(node_local_name); 1167 for (int i = 0; i < elems.getLength(); i++) 1168 { 1169 Element current = (Element) elems.item(i); 1170 boolean nodeMatches = true; 1171 for (int j = 1; j < attribute_names.length; j++) 1172 { 1173 String currentName = attribute_names[j]; 1174 String currentValue = attribute_values[j]; 1175 if (!current.getAttribute(currentName).equals(currentValue)) 1176 { 1177 nodeMatches = false; 1178 break; 1179 } 1180 } 1181 1182 if (nodeMatches) 1183 { 1184 return current; 1185 } 1186 } 1187 return null; 1188 } 1189 1190 1161 1191 public static NodeList getElementsWithAttributesNS(Element parent, String namespace_uri, String node_local_name, String[] attribute_names, String[] attribute_values) 1162 1192 {
Note:
See TracChangeset
for help on using the changeset viewer.