|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javalite.test.XPathHelper
public class XPathHelper
Convenience class for pulling information from XML documents. It provides a set of convenience methods for checking structure and content of XML files. Such files could be XHTML generated for web apps, or any other XML.
| Constructor Summary | |
|---|---|
XPathHelper(String xml)
Use constructor and instance methods to only parse once and reuse a parsed tree. |
|
| Method Summary | |
|---|---|
String |
attributeValue(String xpath)
Returns a value of an attribute. |
static String |
attributeValue(String xpath,
String xml)
Selects a value of attribute. |
int |
count(String xpath)
Counts a collection selected by XPath expression. |
static int |
count(String xpath,
String xml)
Counts a collection selected by XPath expression. |
static List<String> |
selectStrings(String xpath,
String xml)
Selects text nodes as list of strings |
String |
selectText(String xpath)
Retrieves text of a single node. |
static String |
selectText(String xpath,
String xml)
Selects text from a single node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XPathHelper(String xml)
xml - XML to parse.| Method Detail |
|---|
public String selectText(String xpath)
xpath - XPath pointing to a single node (not its text).
public String attributeValue(String xpath)
xpath - needs to point to an attribute of a single node.
public int count(String xpath)
xpath - expression which muse evaluate to a list of items.
public static String selectText(String xpath,
String xml)
xpath - expression that points to a single node.xml - document.
public static int count(String xpath,
String xml)
xpath - expression which mus evaluate to a list of items.xml - xml document.
public static String attributeValue(String xpath,
String xml)
xpath - expression that points to a specific attribute of a specific node. Example: /a/b[1]/@id.xml - document.
public static List<String> selectStrings(String xpath,
String xml)
xpath - xpath expression, should end with text() function, example: "//name/text()"xml - xml to get strings from.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||