从XML文件读取值引发错误-FAKE F#MAKE [英] Reading value from XML file Throws an error - FAKE F#MAKE
问题描述
我正在尝试从FAKE读取XML文件中的值,但出现错误
I am trying to read value from XML file from FAKE , But I am getting an error i.e.
.fsx(9,16) : eror FS000: Incomplete structurd construct at or before this
point in expression. Expected '->' or other token.
下面是我的代码,我正在使用XMLHelper.XMLRead
从xml文件读取值.
Below is my code , I am using XMLHelper.XMLRead
to read values from xml file .
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.XMLHelper
Target "BuildMain" (fun _ ->
for s in XMLHelper.XMLRead true "D:/test/Version.Config" "/version/major/minor"
trace s)
"BuildMain"
RunTargetOrDefault "BuildMain"
下面是我的XML文件:
Below is my XML File :
<version>
<major number="2">
<minor>1</minor>
<build>1</build>
<revised>1</revised>
</major>
</version>
在这里,我尝试从次要版本中读取值,此外,我可以将该值存储在变量中,以便以后使用吗?
Here I am trying to read value from minor version , and moreover can I store this value in a variable so that I can use this later ??
推荐答案
for ... in
构造在正文之前需要do
或箭头->
:
The for ... in
construct requires either do
or an arrow ->
before the body:
for s in XMLHelper.XMLRead true "D:/test/Version.Config" "/version/major/minor" do
trace s
如果主体是另一个循环或仅是副作用代码,则使用do
,例如:
You use do
if the body is another loop or just side-effecting code, as in:
for x in 1..5 do
printfn "%d" x
您使用箭头->
使主体产生一个值,然后该值成为结果列表或序列的一部分,如下所示:
You use arrow ->
to have the body produce a value, which then becomes part of the resulting list or sequence, as in:
let evenNumbers2to10 = [for x in 1..5 -> x*2]
箭头->
可以用作do yield
的快捷方式:
The arrow ->
can be viewed as a shortcut for do yield
:
let evenNumbers2to10 = [for x in 1..5 do yield x*2]
这篇关于从XML文件读取值引发错误-FAKE F#MAKE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!