A powerful tool to parse xml -- Xpath!
Posted pp_crz_coder
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A powerful tool to parse xml -- Xpath!相关的知识,希望对你有一定的参考价值。
The Xpath‘s javadoc could be got from the Dom4j‘s javadoc.
There are some simple regulation you must follow:
1.When you want to use specific single node:
/AAA
/AAA/CCC
2.When you want to use all the nodes which have the same name:
//BBB
//DDD/CCC
3. * represent all the nodes in the specific path:
/AAA/*
//* ---------> all the nodes
4.The expression which has the square brackets could further specify the node. The number in the bracket gives the position you select/
/AAA[1]
//BBB/CCC[last()]
5.The attribute will be got by the @
//@id
/AAA[@id]
But after knowing the regulation , where should we put it?
//Get the document object
SAXReader reader = new SAXReader();
Document document = reader.read("");
//get the data of node via document‘s selecNodes() or selectSingleNode()
List<Node> nodes = document.selectNodes(" you can set your regulation here!!");
Node node = document.selectSingleNode(" you can set your regulation here!!");
以上是关于A powerful tool to parse xml -- Xpath!的主要内容,如果未能解决你的问题,请参考以下文章
Visual Studio Productivity Power Tools居然也开源
如何在 Power BI 中解析 a-ofx-version-1-0-2-file?
VS2019 使用EF Core Power Tools 生成Sqlserver的数据库实体类
第三篇:Entity Framework CodeFirst & Model 映射 续篇 EntityFramework Power Tools 工具使用