3

我已经使用 Delphi 2010 中的 XML 数据绑定向导从 Citrix Web Interface解析了PNAgent.dtd文件,是生成的单元。

然后我尝试用它读取以下 XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PNAgent_Configuration SYSTEM "PNAgent.dtd"[]>
<PNAgent_Configuration xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
    <FolderDisplay>
        <StartMenuDisplay>
            <Enabled>true</Enabled>
            <RootFolder root="programs">
            </RootFolder>
        </StartMenuDisplay>
        <DesktopDisplay>
            <Enabled>false</Enabled>
            <Icon>
                <Name>
                </Name>
            </Icon>
        </DesktopDisplay>
        <SystemTrayMenuDisplay>
            <Enabled>true</Enabled>
        </SystemTrayMenuDisplay>
    </FolderDisplay>
    <DesktopIntegration>
        <StartMenu>add</StartMenu>
        <Desktop>add</Desktop>
    </DesktopIntegration>
    <ConfigurationFile>
        <Location modifiable="true" forcedefault="false" replaceServerLocation="true" RedirectNow="false">http://2003xa/Citrix/PNAgent/config.xml</Location>
        <Refresh>
            <OnApplicationStart>false</OnApplicationStart>
            <OnResourceRequest>false</OnResourceRequest>
            <Poll>
                <Enabled>false</Enabled>
                <Period>8</Period>
            </Poll>
        </Refresh>
    </ConfigurationFile>
    <Request>
        <Enumeration>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/enum.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_enum.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_enum.aspx</Integrated_Location>
            <Refresh>
                <OnApplicationStart modifiable="false" forcedefault="true">true</OnApplicationStart>
                <OnResourceRequest modifiable="false" forcedefault="true">false</OnResourceRequest>
                <Poll modifiable="false" forcedefault="true">
                    <Enabled>true</Enabled>
                    <Period>6</Period>
                </Poll>
            </Refresh>
        </Enumeration>
        <Resource>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/launch.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_launch.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_launch.aspx</Integrated_Location>
        </Resource>
        <Reconnect>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/reconnect.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_reconnect.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_reconnect.aspx</Integrated_Location>
        </Reconnect>
        <Change_Password>
            <Location replaceServerLocation="true" modifiable="true" forcedefault="false" RedirectNow="false">http://2003xa/Citrix/PNAgent/change_password.aspx</Location>
        </Change_Password>
        <MachineControl>
            <Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/desktopControl.aspx</Location>
            <Smartcard_Location replaceServerLocation="true">https://2003xa/Citrix/PNAgent/smartcard_desktopControl.aspx</Smartcard_Location>
            <Integrated_Location replaceServerLocation="true">http://2003xa/Citrix/PNAgent/integrated_desktopControl.aspx</Integrated_Location>
        </MachineControl>
    </Request>
    <Failover>
    </Failover>
    <Logon>
        <LogonMethod>prompt</LogonMethod>
        <EnableSmartcardPromptAutoLogon>false</EnableSmartcardPromptAutoLogon>
        <EnableSavePassword>false</EnableSavePassword>
        <EnableKerberos>false</EnableKerberos>
        <SupportNDS>false</SupportNDS>
        <NDS_Settings>
            <DefaultTree>
            </DefaultTree>
        </NDS_Settings>
        <CaptureSmartCardPin>false</CaptureSmartCardPin>
    </Logon>
    <ChangePassword>
        <Allow>Never</Allow>
        <Method>Direct-Only</Method>
    </ChangePassword>
    <UserInterface>
        <ServerSettings>true</ServerSettings>
        <FolderDisplaySettings>true</FolderDisplaySettings>
        <RefreshSettings>false</RefreshSettings>
        <ReconnectSettings>true</ReconnectSettings>
    </UserInterface>
    <ReconnectOptions>
        <ReconnectFromLogon>
            <Disconnected>true</Disconnected>
            <Active>true</Active>
        </ReconnectFromLogon>
        <ReconnectFromButton>
            <Disconnected>true</Disconnected>
            <Active>true</Active>
        </ReconnectFromButton>
    </ReconnectOptions>
    <FileCleanup>
        <Logoff>false</Logoff>
        <Exit>false</Exit>
        <RefreshApp directoryDepth="0">true</RefreshApp>
    </FileCleanup>
    <ICA_Options>
        <DisplaySize>
            <Options>
                <Mode>seamless</Mode>
                <Mode>fullscreen</Mode>
                <Dimension>
                    <Width>640</Width>
                    <Height>480</Height>
                </Dimension>
                <Dimension>
                    <Width>800</Width>
                    <Height>600</Height>
                </Dimension>
                <Dimension>
                    <Width>1024</Width>
                    <Height>768</Height>
                </Dimension>
                <Dimension>
                    <Width>1280</Width>
                    <Height>1024</Height>
                </Dimension>
                <Dimension>
                    <Width>1600</Width>
                    <Height>1200</Height>
                </Dimension>
            </Options>
        </DisplaySize>
        <ColorDepth>
            <Options>4</Options>
            <Options>8</Options>
        </ColorDepth>
        <Audio>
            <Options>high</Options>
            <Options>medium</Options>
            <Options>low</Options>
            <Options>off</Options>
        </Audio>
        <TransparentKeyPassthrough>
            <Options>local</Options>
            <Options>remote</Options>
            <Options>fullscreenonly</Options>
        </TransparentKeyPassthrough>
        <SpecialFolderRedirection modifiable="false">
            <Enabled>false</Enabled>
        </SpecialFolderRedirection>
    </ICA_Options>
    <AppAccess>
        <AppAccessMethod>Remote</AppAccessMethod>
    </AppAccess>
</PNAgent_Configuration>

为什么 PNAgent.Request.Enumeration.Location.ReplaceServerLocation 是一个空字符串,而不是我期望的“http://2003xa/Citrix/PNAgent/enum.aspx”?

procedure TForm1.Button3Click(Sender: TObject);
var
  XML: IXMLDocument;
  PNAgent: IXMLPNAgent_ConfigurationType;
begin
  XML := TXMlDocument.Create(nil);
  XML.LoadFromFile('config.xml');
  PNAgent := NewPNAgent_Configuration;
  PNAgent.Text := XML.XML.Text;
  Memo1.Lines.Add(Format('Server Location: %s', [PNAgent.Request.Enumeration.Location.ReplaceServerLocation]));

当我检查 PNAgent.Request.XML 的值时,它显示了这一点(值似乎丢失了):

'<Request><Enumeration><Location replaceServerLocation=""/></Enumeration></Request>'
4

1 回答 1

2

当我注意到除了 LoadXMLDocument 之外,生成的单元中还有一个 LoadPNAgent_Configuration 时,我想测试 TLama 的答案。当我尝试它完美地工作时!

procedure TForm1.Button3Click(Sender: TObject);
var
  XML: IXMLDocument;
  PNAgent: IXMLPNAgent_ConfigurationType;
begin
  PNAgent := LoadPNAgent_Configuration('config.xml');
  Memo1.Lines.Add(Format('Server Location: %s', [PNAgent.Request.Enumeration.Location.NodeValue]));
end;

实现是:

function LoadPNAgent_Configuration(const FileName: string): IXMLPNAgent_ConfigurationType;
begin
  Result := LoadXMLDocument(FileName).GetDocBinding('PNAgent_Configuration', TXMLPNAgent_ConfigurationType, TargetNamespace) as IXMLPNAgent_ConfigurationType;
end;
于 2012-05-18T14:11:46.890 回答