我在从POM中提取版本号时遇到问题.有人能帮我吗?

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <artifactId>watcher</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <groupId>com.test.file</groupId>
    <name>file-watcher</name>
    <packaging>jar</packaging>

    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <relativePath/>
        <version>2.6.1</version> 
    </parent>

</project>

XPATH Expression:

//project/version/text()

Error:这将返回未找到匹配项

推荐答案

Your XPath here is correct, it should return 0.0.1-SNAPSHOT
It can be simulated on XPath simulators like this
This is what I see there
So it's quite clear your problem is not with the XPath expression while with what you doing with it.

Python相关问答推荐

零填充2D数组上的Numpy切片

计算每月过go x年的平均值

如何使用stride_tricks.as_strided逆转NumPy数组

LAB中的增强数组

使用plotnine和Python构建地块

SQLGory-file包FilField不允许提供自定义文件名,自动将文件保存为未命名

可变参数数量的重载类型(args或kwargs)

log 1 p numpy的意外行为

Julia CSV for Python中的等效性Pandas index_col参数

如何在WSL2中更新Python到最新版本(3.12.2)?

在极性中创建条件累积和

形状弃用警告与组合多边形和多边形如何解决

当点击tkinter菜单而不是菜单选项时,如何执行命令?

Django RawSQL注释字段

在www.example.com中使用`package_data`包含不包含__init__. py的非Python文件

考虑到同一天和前2天的前2个数值,如何估算电力时间序列数据中的缺失值?

无论输入分辨率如何,稳定扩散管道始终输出512 * 512张图像

OpenCV轮廓.很难找到给定图像的所需轮廓

python sklearn ValueError:使用序列设置数组元素

BeautifulSoup-Screper有时运行得很好,很健壮--但有时它失败了::可能这里需要一些更多的异常处理?