问题描述
我想检查具有Op =A或E的ProtectionOrder中的第一个状态是否与具有Op =A或E的MNProtectionOrderAdditional中的第一个状态相同。
如果它们不相等,我会抛出一个系统错误,例如抛出新的System.Exception(状态不同步。详细信息选项卡与附加不匹配选项卡状态。)
如何在VB.Net中使用if语句执行此操作?
在我的Vb.Net代码中,xml文档位于 aobjXmlInputDoc 对象中。所以要获得状态元素我会这样做
用简单的英语我的逻辑看起来像这样
如果是Op的第一个状态=来自ProtectionOrder的A或E<>从MNProtectionOrderAdditional然后返回第一个状态
抛出新的System.Exception(状态不同步。详细信息选项卡与其他选项卡状态不匹配。)
结束如果
这是我的xml文档。
I would like to check if the first status in ProtectionOrder with Op="A" or "E" is the same as first status in MNProtectionOrderAdditional with Op="A" or "E".
If they are not equal, I will throw a system error like this Throw New System.Exception("Statuses out of sync. The detail tab does Not match the additional tab status.")
How do I do this using if statement in VB.Net?
In my Vb.Net code, the xml document is in aobjXmlInputDoc object. So to get Status element I will do it this way
In plain English my logic will look like this
If the first status with Op=A or E from ProtectionOrder <> to first Status from MNProtectionOrderAdditional Then
Throw New System.Exception("Statuses out of sync. The detail tab does Not match the additional tab status.")
End If
Here is my xml document.
<Integration>
<ProtectionOrder>
<Statuses>
<Status Op="A">
<Current>true</Current>
<Active>No</Active>
<Date Op="A">12/13/2018</Date>
<Type Op="A" Word="EXPIRED">Expired</Type>
</Status>
<Status>
<Current>false</Current>
<Active>Yes</Active>
<Date>12/13/2016</Date>
<Type Word="SBJO">Signed By Judicial Officer</Type>
</Status>
<Status>
<Current>false</Current>
<Active>No</Active>
<Date>12/13/2016</Date>
<Type Word="DRAFT">Draft</Type>
</Status>
</Statuses>
<MNProtectionOrderAdditional>
<Statuses>
<Status Op="A">
<Current>false</Current>
<Active>No</Active>
<Date Op="A">12/13/2018</Date>
<Type Op="A" Word="EXPIRED">Expired</Type>
</Status>
<Status>
<Current>false</Current>
<Active>Yes</Active>
<Date>12/13/2016</Date>
<Type Word="SBJO">Signed By Judicial Officer</Type>
</Status>
<Status>
<Current>true</Current>
<Active>No</Active>
<Date>12/13/2016</Date>
<Type Word="DRAFT">Draft</Type>
</Status>
</Statuses>
</MNProtectionOrderAdditional>
</ProtectionOrder>
</Integration>
我尝试了什么:
这是我正在尝试但需要帮助的。
What I have tried:
This is what I am trying but need help with it.
In VB.Net I am not sure how to do it. This is where I need help.
If aobjXmlInputDoc.DocumentElement.SelectSingleNode("Integration/ProtectionOrder/Statuses/Status[1]/@Op") <> aobjXmlInputDoc.DocumentElement.SelectSingleNode ("Integration/ProtectionOrder/MNProtectionOrderAdditional/Statuses/Status[1]/@Op") Then
Throw New System.Exception("Statuses out of sync. The detail tab does Not match the additional tab status.")
End If
推荐答案
If aobjXmlInputDoc.DocumentElement.SelectSingleNode("Integration/ProtectionOrder/Statuses/Status[1]/@Op").Value <> aobjXmlInputDoc.DocumentElement.SelectSingleNode ("Integration/ProtectionOrder/MNProtectionOrderAdditional/Statuses/Status[1]/@Op").Value Then
这篇关于如何检查来自protectionorder父节点的第一个状态元素是否等于来自mnprotectionorderadditional父节点的第一个状态元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!