How to select two attributes from the same node with one expression in XPath?

前端 未结 4 1255
悲&欢浪女
悲&欢浪女 2020-12-04 18:59

For example:

//person[@id=\'abc123\']/@haircolor|/@weight\"

PS. there are lots of \"person\" records

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 19:50

    Try this:

    //person[@id='abc123']/@*[name()='weight' or name()='haircolor']
    

    If you're using an XPath 2.0 processor, you may also use a prettier option:

    //person[@id='abc123']/(@haircolor|@weight)`
    

提交回复
热议问题