本文整理匯總了Java中cn.wanghaomiao.xpath.exception.NoSuchAxisException類的典型用法代碼示例。如果您正苦於以下問題:Java NoSuchAxisException類的具體用法?Java NoSuchAxisException怎麽用?Java NoSuchAxisException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NoSuchAxisException類屬於cn.wanghaomiao.xpath.exception包,在下文中一共展示了NoSuchAxisException類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sel
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
public List<Object> sel(String xpath) throws XpathSyntaxErrorException {
List<Object> res = new LinkedList<Object>();
try {
List<JXNode> jns = xpathEva.xpathParser(xpath,elements);
for (JXNode j:jns){
if (j.isText()){
res.add(j.getTextVal());
}else {
res.add(j.getElement());
}
}
} catch (Exception e){
String msg = "please check the xpath syntax";
if (e instanceof NoSuchAxisException||e instanceof NoSuchFunctionException){
msg = e.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
return res;
}
示例2: selNFirst
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
/**
*
* @param xpath
* @return 返回匹配到的第一個元素。如果沒有則返回空JXNode對象。
* @throws XpathSyntaxErrorException
*/
public JXNode selNFirst(String xpath) throws XpathSyntaxErrorException {
try {
List<JXNode> list=selN(xpath);
if(list.size()==0) {
JXNode temp=new JXNode();
temp.setTextVal("");
return temp;
}else {
return selN(xpath).get(0);
}
}catch (Exception e){
String msg = "please check the xpath syntax";
if (e instanceof NoSuchAxisException ||e instanceof NoSuchFunctionException){
msg = e.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
}
示例3: selFirst
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
/**
*
* @param xpath
* @return 返回匹配到的第一個元素內容。如果是文本則返回文本,否則返回null
* @throws XpathSyntaxErrorException
*/
public String selFirst(String xpath) throws XpathSyntaxErrorException {
try {
List<JXNode> list=selN(xpath);
if(list.size()==0) {
Object temp=new Object();
return "";
}else if(list.get(0).isText()){
return list.get(0).getTextVal();
}else {
return null;
}
}catch (Exception e){
String msg = "please check the xpath syntax";
if (e instanceof NoSuchAxisException ||e instanceof NoSuchFunctionException){
msg = e.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
}
示例4: selString
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
public List<String> selString(String xpath){
LinkedList<String> res = new LinkedList<>();
try {
List e = this.xpathEva.xpathParser(xpath, this.elements);
Iterator msg1 = e.iterator();
while(msg1.hasNext()) {
JXNode j = (JXNode)msg1.next();
if(j.isText()) {
res.add(j.getTextVal());
} else {
res.add(j.getElement().html());
}
}
return res;
} catch (Exception var6) {
String msg = "please check the xpath syntax";
if(var6 instanceof NoSuchAxisException || var6 instanceof NoSuchFunctionException) {
msg = var6.getMessage();
}
throw new XpathSyntaxException(msg);
}
}
示例5: sel
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
public List<Object> sel(String xpath) throws XpathSyntaxErrorException {
LinkedList res = new LinkedList();
try {
List e = this.xpathEva.xpathParser(xpath, this.elements);
Iterator msg1 = e.iterator();
while(msg1.hasNext()) {
JXNode j = (JXNode)msg1.next();
if(j.isText()) {
res.add(j.getTextVal());
} else {
res.add(j.getElement());
}
}
return res;
} catch (Exception var6) {
String msg = "please check the xpath syntax";
if(var6 instanceof NoSuchAxisException || var6 instanceof NoSuchFunctionException) {
msg = var6.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
}
示例6: selN
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
public List<JXNode> selN(String xpath) throws XpathSyntaxErrorException{
try {
return xpathEva.xpathParser(xpath,elements);
}catch (Exception e){
String msg = "please check the xpath syntax";
if (e instanceof NoSuchAxisException||e instanceof NoSuchFunctionException){
msg = e.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
}
示例7: xpathParser
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
/**
* xpath解析器的總入口,同時預處理,如‘|’
*
* @param xpath
* @param root
* @return
*/
public List<JXNode> xpathParser(String xpath, Elements root) throws NoSuchAxisException, NoSuchFunctionException {
if (xpath.contains("|")) {
List<JXNode> rs = new LinkedList<JXNode>();
String[] chiXpaths = xpath.split("\\|");
for (String chiXp : chiXpaths) {
if (chiXp.length() > 0) {
rs.addAll(evaluate(chiXp.trim(), root));
}
}
return rs;
} else {
return evaluate(xpath, root);
}
}
示例8: getAxisScopeEls
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
/**
* 調用軸選擇器
*
* @param axis
* @param e
* @return
* @throws NoSuchAxisException
*/
public Elements getAxisScopeEls(String axis, Element e) throws NoSuchAxisException {
try {
String functionName = CommonUtil.getJMethodNameFromStr(axis);
Method axisSelector = axisFuncs.get(renderFuncKey(functionName, e.getClass()));
return (Elements) axisSelector.invoke(SingletonProducer.getInstance().getAxisSelector(), e);
} catch (Exception e1) {
throw new NoSuchAxisException("this axis is not supported,plase use other instead of '" + axis + "'");
}
}
示例9: selN
import cn.wanghaomiao.xpath.exception.NoSuchAxisException; //導入依賴的package包/類
public List<JXNode> selN(String xpath) throws XpathSyntaxErrorException {
try {
return this.xpathEva.xpathParser(xpath, this.elements);
} catch (Exception var4) {
String msg = "please check the xpath syntax";
if(var4 instanceof NoSuchAxisException || var4 instanceof NoSuchFunctionException) {
msg = var4.getMessage();
}
throw new XpathSyntaxErrorException(msg);
}
}