使用linq从xml中获取不同节点的属性值
我有一个 xml 文件,其数据如下
<P1 type="CP" name="E01+W">
<DNo>4423</DNo>
<CNo>abc</CNo>
</P1>
<P2 type="DP" name="E02+W">
<DNo>5623</DNo>
<CNo>xyz</CNo>
</P2>
如何在一列中获取 P1 和 P2 节点的属性值 type="CP" 和 "DP"。 更像是遍历到每个节点及其子节点并获取一列中的每个子节点类型属性值。
Type Name
CP EO1
DP EO2
I have a xml file with data as follows
<P1 type="CP" name="E01+W">
<DNo>4423</DNo>
<CNo>abc</CNo>
</P1>
<P2 type="DP" name="E02+W">
<DNo>5623</DNo>
<CNo>xyz</CNo>
</P2>
How to I get Attribute value type="CP" and "DP" of P1 and P2 node in one column.
More like Traverse to each node of and its sub node and get each subnode type attribute value in one column.
Type Name
CP EO1
DP EO2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 XDocument
You can use XDocument