获取 XMLNode 属性的值

Dot*_*row 1 xml vb.net asp.net xpath

我正在研究 asp.net 应用程序。我有一个这样的功能:

   Public Function ExtractText(node As XmlNode) As String

   End Function
Run Code Online (Sandbox Code Playgroud)

我需要将以下 XML 作为输入传递给上述函数:

<myrequirements Id="7743" Type="tcg_Concept20_sc_323256419566173_context" StartNode="2724" EndNode="2869">
</myrequirements>
Run Code Online (Sandbox Code Playgroud)

然后我需要获取 StartNode 和 EndNode 属性值。

我是否需要使用 XPath。请建议。

问候, 阿西夫

Dar*_*rov 5

您可以尝试使用node.Attributes("StartNode").Valueandnode.Attributes("EndNode").Value假设作为参数传递的 XmlNode 实例包含您的问题中显示的 XML 节点,它将为您提供这两个属性的值。