xml - VB.NET xml 节点
问题描述
我有以下 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>
解决方案
尝试XPathSelectElement
nodelist = doc?.XPathSelectElement("/TaskOfArrayOfCorporationn0S_PdIRS/Result")
If nodelist Is Nothing Then
'path was not found.
End If
Nothing
如果找不到路径,将返回。
推荐阅读
- sql-server - IF EXISTS 部分查询未执行
- c++ - 如何遍历具有两个节点的链接节点
- ruby-on-rails - 我的 rails 项目有两个不同的 I18n.load_path 和 I18n.locale
- ios - 当应用不在应用商店中时,Firebase 动态链接未在开发应用中打开
- css - 在一列中显示按钮和 ul 并居中
- neo4j - Neo4j 是否有更有效的方法来编写多个 where-contains?
- tensorflow - 带有手工构建的图像数据生成器的 keras fit_generator():内存不足
- javascript - 在 JS 中用不同的数组替换对象数组
- python - 将 csv 打印到路径
- javascript - _proto_ 和原型不相等