Inno setup Inno设置:提取XML节点并显示它

Inno setup Inno设置:提取XML节点并显示它,inno-setup,Inno Setup,我有下面的代码,我想把它解压缩成纯文本,但我无法做到这一点 代码可以工作,但我需要的是在ExpandConstant字段中显示它。 我试过几种方法,但到目前为止运气不好 function LoadValueFromXML(const AFileName, APath: string): string; var XMLNode: Variant; XMLDocument: Variant; begin Result := '';

我有下面的代码,我想把它解压缩成纯文本,但我无法做到这一点

代码可以工作,但我需要的是在
ExpandConstant
字段中显示它。 我试过几种方法,但到目前为止运气不好

    function LoadValueFromXML(const AFileName, APath: string): string;
    var
      XMLNode: Variant;
      XMLDocument: Variant;  
    begin
      Result := '';
      XMLDocument := CreateOleObject('Msxml2.DOMDocument.3.0');
      try
        XMLDocument.async := False;
        XMLDocument.load(AFileName);
        if (XMLDocument.parseError.errorCode <> 0) then
          MsgBox('The XML file could not be parsed. ' + 
            XMLDocument.parseError.reason, mbError, MB_OK)
        else
        begin
          XMLDocument.setProperty('SelectionLanguage', 'XPath');
          XMLNode := XMLDocument.selectSingleNode(APath);
          Result := XMLNode.text;
        end;
      except
        MsgBox('An error occured!' + #13#10 + GetExceptionMessage, mbError, MB_OK);
      end;
    end;

    procedure CurPageChanged(CurPageID: Integer);
    begin
      if CurPageID = CustomPageID then
        CustomEdit.Text := LoadValueFromXML('C:\Games\World_of_Tanks_test\WoTLauncher.xml', '//info/patch_info_urls/item');
    end;

   procedure ClienteWot();
    var
      StaticText: TNewStaticText;
    begin
      StaticText := TNewStaticText.Create(WizardForm);
      StaticText.Parent := WizardForm.SelectComponentsPage;
      StaticText.Left := 425;
      StaticText.Top := ScaleY(40);
      StaticText.Font.Style := [fsBold];
      //StaticText.Font.Color := clRed;
      StaticText.Caption := ExpandConstant('Cliente WOT: -->>> Show XML Url <<<---');
    end;
函数LoadValueFromXML(const-AFileName,APath:string):string;
变量
XMLNode:变体;
XMLDocument:变体;
开始
结果:='';
XMLDocument:=CreateOleObject('Msxml2.DOMDocument.3.0');
尝试
XMLDocument.async:=False;
加载(AFileName);
如果是(XMLDocument.parseError.errorCode 0),则
MsgBox('无法分析XML文件。'+
XMLDocument.parseError.reason,mbError,MB_OK)
其他的
开始
setProperty('SelectionLanguage','XPath');
XMLNode:=XMLDocument.selectSingleNode(APath);
结果:=XMLNode.text;
结束;
除了
MsgBox('发生错误!'+#13#10+GetExceptionMessage,mbError,MB#u OK);
结束;
结束;
过程CurPageChanged(CurPageID:Integer);
开始
如果CurPageID=CustomPageID,则
CustomEdit.Text:=LoadValueFromXML('C:\Games\World\u of_Tanks\u test\wotluncher.xml','//info/patch\u info\u url/item');
结束;
程序ClienteWot();
变量
静态文本:TNewStaticText;
开始
StaticText:=TNewStaticText.Create(WizardForm);
StaticText.Parent:=WizardForm.SelectComponentsPage;
StaticText.Left:=425;
StaticText.Top:=ScaleY(40);
StaticText.Font.Style:=[fsBold];
//StaticText.Font.Color:=clRed;

StaticText.Caption:=ExpandConstant('Cliente WOT:-->>Show XML Url如果要将值内联到可传递给函数调用的字符串中,可以使用以下函数:

var
  ...
  URL: string;
begin
  ...
  URL := LoadValueFromXML('C:\MyFile.xml', '//node/subnode');
  StaticText.Caption := ExpandConstant(Format('{username} %s', [URL]));
end;
上面的伪代码示例读取XML值,并将返回值分配给
URL
变量。然后计算第二行的内部语句:

Format('{username} %s', [URL])
它将
URL
字符串值内联到给定字符串中(代替
%s
),并生成如下字符串:

'{username} www.example.com'
然后,该字符串由函数调用(外部语句)处理,并分配给静态文本标题,例如:

'MyUserName www.example.com'

XML格式不知道行。它有节点。但无论如何,你是在问如何获取整个节点文本,例如
?好的,我不知道,但是的,我想要该节点的值这个值,只是为了确保我满足你的要求(因为我无法想象整个节点文本的用法)。您想只获取该节点的一个值吗,在您的示例中,
此值
。还是整个节点文本(我想这就是您要问的)
此值
?仅“此值”,我不需要整个节点文本。那么,您发布的代码应该能够获取该
补丁信息URL
URL列表的第一个URL(假设我们讨论的XML在WOT论坛的帖子中多次提到;我个人不知道它的格式)。