xpath: select parent and filtered children

后端 未结 1 1067
小蘑菇
小蘑菇 2021-01-20 07:09

Given an xml block of:


    
    

How might I use xpath to re

1条回答
  •  执笔经年
    2021-01-20 08:03

    With just XPath, you can't.

    XPath allows you to query (select) nodes from an XML document tree, but it can't modify a tree or create new nodes. So if you select the original node, it will have two children, and you can't change that. In order to get a with only one child, you'd have to either modify the original to delete its other child, or create a new .

    You could do this with XSLT, as you alluded to; or a number of other XML tree-building technologies. If you tell us what kind of platform you're building on, we could suggest ones that are most relevant to your platform.

    0 讨论(0)
提交回复
热议问题