org.jenkinsci.plugins.neoload_integration.supporting
Class XMLUtilities

java.lang.Object
  extended by org.jenkinsci.plugins.neoload_integration.supporting.XMLUtilities
All Implemented Interfaces:
Serializable

public final class XMLUtilities
extends Object
implements Serializable

See Also:
Serialized Form

Method Summary
static Node createNodeFromText(String xmlText)
          Create an xml Node using the passed in text.
static List<Node> findByExpression(String expression, Node searchNode)
          Return all nodes matching the passed in expression.
static Node findFirstByExpression(String expression, Node searchNode)
          Return the first node matching the passed in expression or null if none was found.
static String findFirstValueByExpression(String expression, Node searchNode)
           
static Map<String,String> getMap(NamedNodeMap attributes)
           
static String nodeToString(Node n)
           
static Document readXmlFile(String srcFile)
          Read an xml file.
static List<Node> toList(NodeList nodeList)
          Turns a NodeList into a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createNodeFromText

public static Node createNodeFromText(String xmlText)
                               throws ParserConfigurationException,
                                      SAXException,
                                      IOException
Create an xml Node using the passed in text. Use getOwnerDocument() to get the document.

Parameters:
xmlText -
Returns:
Throws:
ParserConfigurationException
SAXException
IOException

findByExpression

public static List<Node> findByExpression(String expression,
                                          Node searchNode)
                                   throws XPathExpressionException
Return all nodes matching the passed in expression. Useful path expressions are listed below:
Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
// Selects nodes in the document from the current node that match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

Parameters:
expression - search for this expression
nodes - search this and all child nodes
Returns:
Throws:
XPathExpressionException

findFirstByExpression

public static Node findFirstByExpression(String expression,
                                         Node searchNode)
                                  throws XPathExpressionException
Return the first node matching the passed in expression or null if none was found.

Parameters:
expression -
searchNode -
Returns:
Throws:
XPathExpressionException

findFirstValueByExpression

public static String findFirstValueByExpression(String expression,
                                                Node searchNode)
                                         throws XPathExpressionException
Parameters:
expression -
searchNode -
Returns:
Throws:
XPathExpressionException

getMap

public static Map<String,String> getMap(NamedNodeMap attributes)
Parameters:
attributes -
Returns:
a map where the attribute is the key and the value is the value.

toList

public static List<Node> toList(NodeList nodeList)
Turns a NodeList into a list.

Parameters:
nodeList -
Returns:

nodeToString

public static String nodeToString(Node n)
                           throws TransformerException
Parameters:
n -
Returns:
Throws:
TransformerException

readXmlFile

public static Document readXmlFile(String srcFile)
                            throws ParserConfigurationException,
                                   SAXException,
                                   IOException
Read an xml file.

Parameters:
srcFile -
Returns:
a document created from the passed in file path
Throws:
ParserConfigurationException
SAXException
IOException


Copyright © 2004-2013. All Rights Reserved.