当前位置: 首页>>代码示例>>Java>>正文


Java Document.selectNodes方法代码示例

本文整理汇总了Java中org.dom4j.Document.selectNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Document.selectNodes方法的具体用法?Java Document.selectNodes怎么用?Java Document.selectNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dom4j.Document的用法示例。


在下文中一共展示了Document.selectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query_timestamp

import org.dom4j.Document; //导入方法依赖的package包/类
/**
    * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
    * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
    * @return 时间戳字符串
    * @throws IOException
    * @throws DocumentException
    * @throws MalformedURLException
    */
public static String query_timestamp() throws MalformedURLException,
                                                       DocumentException, IOException {

       //构造访问query_timestamp接口的URL串
       String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + AlipayConfig.partner + "&_input_charset" +AlipayConfig.input_charset;
       StringBuffer result = new StringBuffer();

       SAXReader reader = new SAXReader();
       Document doc = reader.read(new URL(strUrl).openStream());

       List<Node> nodeList = doc.selectNodes("//alipay/*");

       for (Node node : nodeList) {
           // 截取部分不需要解析的信息
           if (node.getName().equals("is_success") && node.getText().equals("T")) {
               // 判断是否有成功标示
               List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
               for (Node node1 : nodeList1) {
                   result.append(node1.getText());
               }
           }
       }

       return result.toString();
   }
 
开发者ID:dianbaer,项目名称:epay,代码行数:34,代码来源:AlipaySubmit.java

示例2: generate

import org.dom4j.Document; //导入方法依赖的package包/类
void generate(File findbugsFile, File messageFile, File output, String[] tags) throws IOException {
    SAXReader reader = new SAXReader();
    try {
        Document message = reader.read(messageFile);
        Document findbugs = reader.read(findbugsFile);

        @SuppressWarnings("unchecked")
        List<Node> bugPatterns = message.selectNodes("/MessageCollection/BugPattern");
        @SuppressWarnings("unchecked")
        List<Node> findbugsAbstract = findbugs.selectNodes("/FindbugsPlugin/BugPattern");

        writePatterns(findbugsAbstract, bugPatterns, output, tags);
    } catch (DocumentException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:KengoTODA,项目名称:sonarqube-rule-xml-generator,代码行数:17,代码来源:RuleXmlGenerator.java

示例3: MqResToDto

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /* 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回 */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        logger.error("", e);
    }
    return map;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:30,代码来源:XmlUtil.java

示例4: MqResToDto

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
	// System.out.println("####recv"+recv);
	List res = new ArrayList();
	Map map = new HashMap();
	try {
		Document doc = DocumentHelper.parseText(recv);
		List list = doc.selectNodes("//item");
		Iterator<DefaultElement> it = list.iterator();
		while (it.hasNext()) {
			Map elementdto = XmlUtil.Dom2Map(it.next());
			res.add(elementdto);
		}
		map.put("resultList", res);// 放入结果集
		/*
		 * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
		 */
		Node de = doc.selectSingleNode("//REC_MNT");
		if (DataUtil.isNotEmpty(de)) {
			map.put("countInteger", de.getText());
		}
	} catch (Exception e) {
		log.error(XmlUtil.class, e);
	}
	return map;
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:32,代码来源:XmlUtil.java

示例5: getValidDrcPathways

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 *  Return a HasMap of valid DRC pathways from the pathways.xsd schema. Both the keys and values cantain the
 *  exact Strings of the valid pathways.
 *
 * @return    HashMap of valid DRC pathways.
 */
private HashMap getValidDrcPathways() {

	if (annotationPathwaysSchemaUrl == null)
		return null;

	HashMap pathways = new HashMap();

	try {
		SAXReader reader = new SAXReader();
		Document document = reader.read(new URL(annotationPathwaysSchemaUrl));
		List nodes = document.selectNodes("//xsd:simpleType[@name='pathwayType']/xsd:restriction/xsd:enumeration");
		for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {
			Node node = (Node) iter.next();
			pathways.put(node.valueOf("@value"), node.valueOf("@value"));
		}
	} catch (Throwable e) {
		prtlnErr("Error getValidDrcPathways(): " + e);
	}

	return pathways;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:28,代码来源:RecordDataService.java

示例6: getValidCollectionKeys

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 *  Grabs the collection keys from the DPC keys schema.
 *
 * @return    A list of valid colleciton keys.
 */
public ArrayList getValidCollectionKeys() {
	String collectionKeySchemaUrl =
		getServlet().getServletContext().getInitParameter("collectionKeySchemaUrl");
	if (collectionKeySchemaUrl == null)
		return null;

	if (validCollectionKeys == null) {
		try {
			validCollectionKeys = new ArrayList();
			SAXReader reader = new SAXReader();
			Document document = reader.read(new URL(collectionKeySchemaUrl));
			validCollectionKeys.add("-- SELECT COLLECTION KEY --");
			List nodes = document.selectNodes("//xsd:simpleType[@name='keyType']/xsd:restriction/xsd:enumeration");
			for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {
				Node node = (Node) iter.next();
				validCollectionKeys.add(node.valueOf("@value"));
			}
		} catch (Throwable e) {
			prtlnErr("Error getCollectionKeys(): " + e);
			validCollectionKeys = null;
		}
	}
	return validCollectionKeys;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:30,代码来源:RepositoryAdminForm.java

示例7: readDocument

import org.dom4j.Document; //导入方法依赖的package包/类
private Document readDocument(String path,String name, int age) throws DocumentException{
	SAXReader reader=new SAXReader();
	Document document=reader.read(path);
	Element root=document.getRootElement();
	List listOfTextView=document.selectNodes("view/body/form/textView");
	for(Iterator<Element> i=listOfTextView.listIterator();i.hasNext();){
		Element textView=i.next();
		if(textView.selectSingleNode("name").getText().equals("userName")){
			textView.selectSingleNode("value").setText(name);
		}
		if(textView.selectSingleNode("name").getText().equals("userAge")){
			textView.selectSingleNode("value").setText(""+age);
		}
	}
	System.out.println(document);
	return document;
}
 
开发者ID:Hang-Hu,项目名称:SimpleController,代码行数:18,代码来源:XmlGenerator.java

示例8: updateJmx

import org.dom4j.Document; //导入方法依赖的package包/类
public static void updateJmx(String jmxFilePath,String csvFilePath,String csvDataXpath) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    Document documentNew =  reader.read(new File(jmxFilePath));
    List<Element> list = documentNew.selectNodes(csvDataXpath);
    if( list.size()>1 ){
        System.out.println("报错");
    }else{
        Element e = list.get(0);
        List<Element> eList = e.elements("stringProp");
        for(Element eStringProp:eList){
            if( "filename".equals( eStringProp.attributeValue("name") ) ){
                System.out.println("==========");
                System.out.println( eStringProp.getText() );
                eStringProp.setText(csvFilePath);
                break;
            }
        }
    }

    XMLWriter writer = new XMLWriter(new FileWriter(new File( jmxFilePath )));
    writer.write(documentNew);
    writer.close();

}
 
开发者ID:wang153723482,项目名称:testing_platform,代码行数:25,代码来源:Tools.java

示例9: query_timestamp

import org.dom4j.Document; //导入方法依赖的package包/类
/**
    * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
    * 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
    * @return 时间戳字符串
    * @throws IOException
    * @throws DocumentException
    * @throws MalformedURLException
    */
public static String query_timestamp(AlipayConfig config) throws MalformedURLException,
                                                       DocumentException, IOException {

       //构造访问query_timestamp接口的URL串
       String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + config.getPartnerId() + "&_input_charset" +AlipayConfig.inputCharset;
       StringBuffer result = new StringBuffer();

       SAXReader reader = new SAXReader();
       Document doc = reader.read(new URL(strUrl).openStream());

       List<Node> nodeList = doc.selectNodes("//alipay/*");

       for (Node node : nodeList) {
           // 截取部分不需要解析的信息
           if (node.getName().equals("is_success") && node.getText().equals("T")) {
               // 判断是否有成功标示
               List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
               for (Node node1 : nodeList1) {
                   result.append(node1.getText());
               }
           }
       }

       return result.toString();
   }
 
开发者ID:superkoh,项目名称:k-framework,代码行数:34,代码来源:AlipaySubmit.java

示例10: main

import org.dom4j.Document; //导入方法依赖的package包/类
public static void main (String [] args) throws Exception {
	String MDPHandle = "2200/test.20070219032201392T";
	String apiUrl = "http://ndrtest.nsdl.org/api";
	String command = "listMembers";
	URL url = new URL (apiUrl + "/" + command + "/" + MDPHandle);
	Document doc = Dom4jUtils.getXmlDocument(url);
	doc = Dom4jUtils.localizeXml(doc);
	pp (doc);
	List mdHandles = new ArrayList();
	List mdHandleNodes = doc.selectNodes("//handleList/handle");
	if (mdHandleNodes != null) {
		for (Iterator i= mdHandleNodes.iterator();i.hasNext();) {
			Node node = (Node)i.next();
			mdHandles.add (node.getText());
		}
	}
	prtln ("Handles (" + mdHandles.size() + ")");
	for (Iterator i = mdHandles.iterator();i.hasNext();) {
		prtln ("\t" + (String)i.next());
	}
	
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:23,代码来源:NdrGetMDHandles.java

示例11: parseAddonInfos

import org.dom4j.Document; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public List<Map<String, Object>> parseAddonInfos(String xml) throws Exception {
	List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
	if (xml == null) {
		return result;
	}
	InputStream inputStream = toInputStream(xml);
	try {
		Document document = saxReader.read(inputStream);
		List list = document.selectNodes("//content/data/content-item");
		Iterator iter = list.iterator();
		while (iter.hasNext()) {
			Map<String, Object> map = new HashMap<String, Object>();
			Element element = (Element) iter.next();
			for (Iterator iterInner = element.elementIterator(); iterInner.hasNext();) {
				Element elementInner = (Element) iterInner.next();
				map.put(elementInner.getName(), elementInner.getText());
			}
			result.add(map);
		}
	} finally {
		inputStream.close();
	}
	return result;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:26,代码来源:NexusAddonParser.java

示例12: getValidMetadataFormats

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 *  Grabs the valid metadata formats from the DPC schema.
 *
 * @return    A list of valid metadata formats.
 */
public ArrayList getValidMetadataFormats() {
	String metadataFormatSchemaUrl =
		getServlet().getServletContext().getInitParameter("metadataFormatSchemaUrl");
	if (metadataFormatSchemaUrl == null)
		return null;

	if (validMetadataFormats == null) {
		try {
			validMetadataFormats = new ArrayList();
			SAXReader reader = new SAXReader();
			Document document = reader.read(new URL(metadataFormatSchemaUrl));
			validMetadataFormats.add("-- SELECT FORMAT --");
			List nodes = document.selectNodes("//xsd:simpleType[@name='itemFormatType']/xsd:restriction/xsd:enumeration");
			for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {
				Node node = (Node) iter.next();
				validMetadataFormats.add(node.valueOf("@value"));
			}
		} catch (Throwable e) {
			prtlnErr("Error getValidMetadataFormats(): " + e);
			validMetadataFormats = null;
		}
	}
	return validMetadataFormats;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:30,代码来源:DCSAdminForm.java

示例13: readXML

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 * 摸查项目输出目录
 * <p>
 * @param projectPath
 * @param kind        output 或 src
 * @return
 */
public static String readXML(String projectPath, String kind) {
    try {
        SAXReader saxReader = new SAXReader();
        File classpath = new File(projectPath + "/.classpath");
        if (classpath.exists()) {
            Document document = saxReader.read(classpath);
            List<Element> out = (List<Element>) document.selectNodes("/classpath/classpathentry[@kind='" + kind + "']");
            String tmp = "";
            for (Element out1 : out) {
                String combineaccessrules = out1.attributeValue("combineaccessrules");
                if ("false".equals(combineaccessrules) && "src".equals(kind)) {
                    continue;
                }
                tmp += out1.attributeValue("path") + ",";
            }
            return tmp.isEmpty() ? tmp : tmp.substring(0, tmp.length() - 1);
        }
    } catch (DocumentException ex) {
        MainFrame.LOGGER.log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
    }
    return "";
}
 
开发者ID:ajtdnyy,项目名称:PackagePlugin,代码行数:31,代码来源:FileUtil.java

示例14: getRoot

import org.dom4j.Document; //导入方法依赖的package包/类
private Element getRoot() {
	Document doc = getDocument();
	List<Element> list = doc.selectNodes("//application");
	if (list.size() > 0) {
		Element aroot = list.get(0);
		return aroot;
	}
	return null;
}
 
开发者ID:zhaoshiling1017,项目名称:voyage,代码行数:10,代码来源:ClientConfig.java

示例15: parseConfig

import org.dom4j.Document; //导入方法依赖的package包/类
/**
 * Parse connection entries out of the given document.
 * @param doc
 */

protected void parseConfig(Document doc) {
    config.clear();
    @SuppressWarnings("unchecked")
    List<Element> list = doc.selectNodes("//FilterDrupal_Connection/connection[@key]");
    for (Element el : list) {
        config.put(el.attributeValue("key").trim(), parseConnectionElement(el));
    }
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:14,代码来源:DrupalMultisiteAuthModule.java


注:本文中的org.dom4j.Document.selectNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。