按属性值选择 XML 节点

Fra*_*oty 3 .net xml f#

<location>
  <hotspot name="name1" X="444" Y="518" />
  <hotspot name="name2" X="542" Y="452" /> 
  <hotspot name="name3" X="356" Y="15" />
</location>
Run Code Online (Sandbox Code Playgroud)

我有一个点变量,我需要选择节点及其坐标,然后更改属性值。我想做类似的事情:

<location>
  <hotspot name="name1" X="444" Y="518" />
  <hotspot name="name2" X="542" Y="452" /> 
  <hotspot name="name3" X="356" Y="15" />
</location>
Run Code Online (Sandbox Code Playgroud)

但通过变量获取属性值(变量名.X / 变量名.Y)。

Fra*_*oty 5

这真的很容易。假设我想修改节点中的第一个属性:

let node = xmld.SelectSingleNode("/location/hotspot[@X='" + string(current.X) + "'] [@Y='" + string(current.Y) + "']")
node.Attributes.[0].Value <- v
Run Code Online (Sandbox Code Playgroud)

其中“当前”是我的变量;)