Package ubic.gemma.core.util
Class XMLUtils
java.lang.Object
ubic.gemma.core.util.XMLUtils
Handy methods for dealing with XML.
- Author:
- pavlidis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XPathExpressionCompile an XPath expression.static DocumentBuildercreateDocumentBuilder(EntityResolver entityResolver) Create a new DocumentBuilder with some good presets for general usage.static NodeListevaluate(XPathExpression xpath, Node item) Evaluate an XPath expression that produces aNodeList.static StringevaluateToString(XPathExpression xpath, Node item) Evaluate an XPath expression that produces aNodeList.extractMultipleChildren(Node parent, String elementName) static NodeextractOneChild(Node parent, String elementName) static StringextractOneChildText(Node parent, String elementName) static Collection<String> extractTagData(Document doc, String tag) static NodeObtain an item from aNodeListat a given index.static StringgetTextValue(Node ele) Make the horrible DOM API slightly more bearable: get the text value we know this element contains.static NodegetUniqueItem(NodeList nodeList) Obtain a single item from aNodeList.
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
createDocumentBuilder
Create a new DocumentBuilder with some good presets for general usage.For security reasons (and also performance), an
EntityResolvermust be supplied to resolve DTDs or XSD schemas. -
extractMultipleChildren
-
extractOneChildText
-
extractOneChild
-
extractTagData
- Parameters:
doc- - the xml document to search throughtag- -the name of the element we are looking for- Returns:
- a collection of strings that represent all the data contained within the given tag (for each instance of that tag)
-
getItem
Obtain an item from aNodeListat a given index. -
getUniqueItem
Obtain a single item from aNodeList. -
getTextValue
Make the horrible DOM API slightly more bearable: get the text value we know this element contains. Borrowed from the Spring API. Using Node.getTextContent() to fix failing tests, if there is a problem, see history before Feb 22. 2018 Also, this is the previous note (related to the code I removed): * Note that we can't really use the alternative Node.getTextContent() because it isn't supported by older Xerces * implementations (1.x), which tend to leak into the classloader. Causes recurring problems with tests.- Parameters:
ele- element- Returns:
- text value
-
compile
Compile an XPath expression. -
evaluate
Evaluate an XPath expression that produces aNodeList. -
evaluateToString
Evaluate an XPath expression that produces aNodeList.
-