我有以下xml,我需要从同一个查询中获得2个值(请参阅*注释): 这两个值是关联的,我可以获得一组() or the other() but not using a single query.
找到一个节点,它在一个查询中匹配后代节点
Update I updated the xml below to include 2 nodes that exist under the node and added the namespace
Ideally I would like to get them both in a single query into a Dictionary
<root xmlns="http://www.blah.net/xsd/layout/2003-10-16">
<header/>
<movement>
<movementHeader>
<desc>xyz</desc>
</movementHeader>
<detailHeader>
<desc>abc</desc>
</detailHeader>
<detail>
<!-- * need this value -->
<code>90125</code>
<subDetail>
<!-- * and need this value at same time -->
<amount>1200.00</amount>
</subDetail>
</detail>
<detail>
<!-- * need this value -->
<code>90126</code>
<subDetail>
<!-- * and need this value at same time -->
<amount>1300.00</amount>
</subDetail>
</detail>
<detail>
<!-- * need this value -->
<code>9012</code>
<subDetail>
<!-- * and need this value at same time -->
<amount>1400.00</amount>
</subDetail>
</detail>
</movement>
尝试了您的解决方案,结果没有任何结果。 xml稍微复杂一点(上面已更新),因为它具有添加到节点的奇怪节点,并且它有一个名称空间。我怀疑NS是一个问题,并且将XNamespace添加到您的代码示例中,但仍然不返回结果 – Tab
@Tab:使用'Element((XNamespace)nsString +“tagname”)' – abatishchev
我在发表评论之前尝试了以下内容: XNamespace nsr = Settings.DefaultNamespace; ... 元素(nsr +“代码”)。值, – Tab