相关疑难解决方法(0)

XPath选择多个标签

鉴于这种简化的数据格式:

<a>
    <b>
        <c>C1</c>
        <d>D1</d>
        <e>E1</e>
        <f>don't select this one</f>
    </b>
    <b>
        <c>C2</c>
        <d>D2</d>
        <e>E1</e>
        <g>don't select me</g>
    </b>
    <c>not this one</c>
    <d>nor this one</d>
    <e>definitely not this one</e>
</a>
Run Code Online (Sandbox Code Playgroud)

你会如何选择所有元素的Cs,Ds和Es B

基本上,像:

a/b/(c|d|e)
Run Code Online (Sandbox Code Playgroud)

在我自己的情况,而不是只a/b/,查询导致到选择那些C,D,E节点其实是相当复杂的,所以我想避免这样做:

a/b/c|a/b/d|a/b/e
Run Code Online (Sandbox Code Playgroud)

这可能吗?

xml xpath

119
推荐指数
3
解决办法
12万
查看次数

标签 统计

xml ×1

xpath ×1