我有以下XML,我似乎无法选择合适的节点列表。我正在使用:
nodelist = doc.SelectNodes("/TaskOfArrayOfCorporationn0S_PdIRS/Result")
但这不会返回公司节点。 XML的格式如下:
<TaskOfArrayOfCorporationn0S_PdIRS xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/System.Threading.Tasks">
<Result xmlns:d2p1="Corporations">
<d2p1:Corporation>
<d2p1:AlternateAddress i:nil="true" />
<d2p1:AlternateCity i:nil="true" />
<d2p1:AlternateState i:nil="true" />
<d2p1:AlternateZip i:nil="true" />
<d2p1:BusinessName>GABRIEL’S COFFEE SHOP LLC</d2p1:BusinessName>
<d2p1:BusinessStatus>Active</d2p1:BusinessStatus>
<d2p1:Category>LLC</d2p1:Category>
<d2p1:DateOfIncorporation>2018-05-18T00:00:00</d2p1:DateOfIncorporation>
<d2p1:DissolutionDate i:nil="true" />
<d2p1:Duration i:nil="true" />
<d2p1:ExpirationDate>2019-05-31T00:00:00</d2p1:ExpirationDate>
<d2p1:ForeignBusinessName i:nil="true" /><
<d2p1:RegisteredAgentAddress>532 SILICA RD NW </d2p1:RegisteredAgentAddress>
<d2p1:RegisteredAgentCity>QUINCY</d2p1:RegisteredAgentCity>
<d2p1:RegisteredAgentName>VERONICA SOSA</d2p1:RegisteredAgentName>
<d2p1:RegisteredAgentState>WA</d2p1:RegisteredAgentState>
<d2p1:RegisteredAgentZip>98848 9466</d2p1:RegisteredAgentZip>
<d2p1:StateOfIncorporation>WASHINGTON</d2p1:StateOfIncorporation>
<d2p1:Type>LLC</d2p1:Type>
<d2p1:TypeDescription>WA LIMITED LIABILITY COMPANY</d2p1:TypeDescription>
<d2p1:Ubi>604288731</d2p1:Ubi>
</d2p1:Corporation>
</Result>
答案 0 :(得分:0)
尝试XPathSelectElement
nodelist = doc?.XPathSelectElement("/TaskOfArrayOfCorporationn0S_PdIRS/Result")
If nodelist Is Nothing Then
'path was not found.
End If
如果找不到路径,将返回 Nothing
。