Package org.dspace.app.util
Class XMLUtils
java.lang.Object
org.dspace.app.util.XMLUtils
Simple class to read information from small XML using DOM manipulation
- Author:
- Andrea Bollini
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetElementAttribute(Element dataRoot, String name, String attr) getElementList(Element dataRoot, String name) static StringgetElementValue(Element dataRoot, String name) getElementValueArrayList(Element rootElement, String subElementName, String... fieldsName) root/subElement[]/field1, field2, fieldNgetElementValueList(Element rootElement, String subElementName) static ElementgetSingleElement(Element dataRoot, String name) Return the first element child with the specified name
-
Method Details
-
getElementList
- Parameters:
dataRoot- the starting nodename- the tag name of the child element to find.- Returns:
- the list of all DOM Element with the provided name direct child of the starting node
-
getElementAttribute
- Parameters:
dataRoot- the starting nodename- the name of the sub elementattr- the attribute to get- Returns:
- the value of the attribute for the sub element with the specified name in the starting node
-
getElementValue
- Parameters:
dataRoot- the starting nodename- the name of the sub element- Returns:
- the text content of the sub element with the specified name in the starting node
-
getSingleElement
Return the first element child with the specified name- Parameters:
dataRoot- the starting nodename- the name of sub element to look for- Returns:
- the first child element or null if no present
-
getElementValueList
- Parameters:
rootElement- the starting nodesubElementName- the tag name of the child element to find.- Returns:
- a list of string including all the text contents of the sub element with the specified name. If there are not sub element with the supplied name the method will return null
-
getElementValueArrayList
public static List<String[]> getElementValueArrayList(Element rootElement, String subElementName, String... fieldsName) root/subElement[]/field1, field2, fieldN- Parameters:
rootElement- the starting nodesubElementName- the name of the sub element to work onfieldsName- the names of the sub-sub-elements from which get the text content- Returns:
- a list of array strings. The length of the array is equals to the number of fields required. For any fields the first textual value found in the sub element is used, null if no value is present
-