【发布时间】:2023-02-13 13:15:31
【问题描述】:
我有以下 XML。我想检查具有名为“Key”的元素且值为“response”的 FormField 节点是否为名为“Value”的元素设置了值。如果值元素为空则返回 false 否则返回 true:
<Form>
<FormField>
<Value>Jumper</Value>
<Key>item</Key>
<Label>Item</Label>
<Type>string</Type>
</FormField>
<FormField>
<Value>unsuccessful</Value>
<Key>response</Key>
<Label>Response</Label>
<Type>string</Type>
</FormField>
<FormField>
<Value/>
<Key>notes</Key>
<Label>Notes</Label>
<Type>string</Type>
</FormField>
<Form>
因此,例如以下将返回 true
<FormField>
<Value>unsuccessful</Value>
<Key>response</Key>
<Label>Response</Label>
<Type>string</Type>
</FormField>
以下内容将返回 false
<FormField>
<Value/>
<Key>response</Key>
<Label>Response</Label>
<Type>string</Type>
</FormField>
我怎样才能做到这一点?
【问题讨论】: