本文整理汇总了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);
}
}