仅当子元素标记值匹配时,才从XML列表中选择XML
对于给定的Xml列表仅当子元素标记值匹配时,才从XML列表中选择XML,xml,xml-parsing,notepad++,extract,parent,Xml,Xml Parsing,Notepad++,Extract,Parent,对于给定的Xml列表 <ns:Input> <ns:location>asfsafs</ns:location> <ns:locationevent>xxxx</ns:locationevent> <ns:Action> <ns:name>abc</ns:name> </ns:Action> <ns:Action> <ns:name>ghy</ns:name&
<ns:Input>
<ns:location>asfsafs</ns:location>
<ns:locationevent>xxxx</ns:locationevent>
<ns:Action>
<ns:name>abc</ns:name>
</ns:Action>
<ns:Action>
<ns:name>ghy</ns:name>
</ns:Action>
<ns:Coverage>
<ns:Action>
<ns:name>deg</ns:name>
</ns:Action>>
</ns:Coverage>
<ns:ID>12133</ns:ID>
</ns:Input>
<ns:Input>
<ns:location>asfsafs</ns:location>
<ns:locationevent>yyyy</ns:locationevent>
<ns:Action>
<ns:name>abc</ns:name>
</ns:Action>
<ns:Action>
<ns:name>def</ns:name>
</ns:Action>
<ns:Coverage>
<ns:Action>
<ns:name>def</ns:name>
</ns:Action>
</ns:Coverage>
<ns:ID>12233</ns:ID>
</ns:Input>
<ns:Input>
<ns:location>asfsafs</ns:location>
<ns:locationevent>yyyy</ns:locationevent>
<ns:Action>
<ns:name>abc</ns:name>
</ns:Action>
<ns:Action>
<ns:name>def</ns:name>
</ns:Action>
<ns:Coverage>
<ns:Action>
<ns:name>def</ns:name>
</ns:Action>
</ns:Coverage>
<ns:ID>1423</ns:ID>
</ns:Input>
<ns:Input>
<ns:location>asfsafs</ns:location>
<ns:locationevent>xxxx</ns:locationevent>
<ns:Action>
<ns:name>abc</ns:name>
</ns:Action>
<ns:Action>
<ns:name>ghy</ns:name>
</ns:Action>
<ns:Coverage>
<ns:Action>
<ns:name>deg</ns:name>
</ns:Action>>
</ns:Coverage>
<ns:ID>12</ns:ID>
</ns:Input>
asfsafs
xxxx
abc
ghy
度
>
12133
asfsafs
年份
abc
def
def
12233
asfsafs
年份
abc
def
def
1423
asfsafs
xxxx
abc
ghy
度
>
12
我只想选择符合以下条件的XML
在这里输入代码
<ns:Input>..<ns:locationevent>yyyy</ns:locationevent>..<ns:Action>..<ns:name>def</ns:name>..
<ns:Input>..<ns:Coverage>..<ns:Action>..<ns:name>def</ns:name>..<ns:ID>1423</ns:ID>..</ns:Input>
.yyyy….def。。
……def..1423。。
如果在记事本++中使用以下命令
<ns:Input>(?:(?!</ns:Input>).)*<ns:locationevent>yyyy</ns:locationevent.*?<ns:Action>.*?
<ns:name>def</ns:name>.*?<ns:Coverage>.*?<ns:Action>.*?<ns:name>def</ns:name>(?:(?!</ns:Input>).)*
(1423).*?</ns:Input>
(?:(?!)*yyyy在Notepad++中添加XML工具插件,评估以下xpath表达式并查看其是否有效:
//ns:Input[//ns:name[text()='def']][ns:locationevent[text()='yyyy']][ns:ID[text()='1423']]
这不是regex的工作;您应该尝试xpath之类的方法。另外,您想要的输出是什么?我在帖子中提到,如果使用上述命令,我只需要XML列表中的3TDXML。我不知道“XML列表中的3TDXML”是什么;请编辑您的问题并准确发布所需输出的内容。我需要以下XML作为符合以下条件的输出asfsafs yyy abc def def 1423。请尝试在顶部用
包装您的XML,然后
查看是否对你有用,但没用。你能把它放在屏幕截图上并解释一下吗