0

ルート属性を読み取ろうとしていますが、wizousxml.nshプラグインを使用して読み取ることができません:(

コード自体は単純明快です。

  ${xml::LoadFile} "${WHICH_DIR}" $0
  ${xml::RootElement} $R1 $R0
  !ifdef DEBUGMODE_NSISDBG
    nsisdbg::sendtolog /NOUNLOAD " root : $R1"
  !endif
  ${xml::GotoPath} "${XML_PATH}" $R1
  !ifdef DEBUGMODE_NSISDBG
    nsisdbg::sendtolog /NOUNLOAD "GotoPath '${XML_PATH}' result: $R1 "
  !endif
  ${xml::GetAttribute} "${XML_PARAM}" "${XML_VARIABLE}" $R1
  !ifdef DEBUGMODE_NSISDBG
    nsisdbg::sendtolog /NOUNLOAD "GetAttribute '${XML_PARAM}' result '$R1' : ${XML_VARIABLE} "
  ${xml::SetAttribute} "port" "$EditTextEditText" $0
  ${xml::SaveFile} "agent.xml" $0
  ${xml::Unload}

しかし、出力はまだ私が必要とするものではありません:

<2012.04.17. 13:01:04>  root : agent
<2012.04.17. 13:01:04> GotoPath '/agent/' result: -1 
<2012.04.17. 13:01:04> GetAttribute 'port' result '0' :  

入力XMLファイル:

<?xml version="1.0" encoding="windows-1257"?>
<agent port="0000" loglevel="3">
</agent>

ヒントや助けてくれてありがとう。

4

1 に答える 1

0

いくつかの予備的なポイント:

あなたのサンプルに取り組んでいる間、私はそれに気づきました

  • GetAttribute結果を格納するための2番目のパラメーターとして変数を期待しているため、nsis定数と変数(nsisコンパイラーによって出力される警告を確認する必要があります)の間で混乱する可能性があります。
  • GotoPathファイナルでは動作しません/それを削除することで期待される結果が得られます
  • OutputDebugStringnsisdbgプラグインを使用せず、メッセージをキャッチするためにDebugViewのみを使用するため、コードを変更しました
!include "XML.nsh"

Name "Sample nsisXML"
OutFile "SampleSO.exe"

ShowInstDetails show    

!define XML_PATH "/agent"
!define XML_PARAM "port"
var XML_VARIABLE 

!define DEBUG `System::Call kernel32::OutputDebugString(ts)`

!macro GetXMLParam PATH PARAM VARIABLE
    ${xml::GotoPath} "${PATH}" $R1
    ${DEBUG} "GotoPath '${PATH}' result: $R1 "
    ${xml::GetAttribute} "${PARAM}" ${VARIABLE} $R1
    ${DEBUG} "GetAttribute '${PARAM}' result '$R1' : ${VARIABLE} "
!macroend

Section "Main program"

    ${xml::LoadFile} "so.xml" $0
    ${xml::RootElement} $R1 $R0
    ${DEBUG} " root : $R1"

    !insertmacro GetXMLParam "/agent" "port" $XML_VARIABLE
;        ${xml::GotoPath} "${XML_PATH}" $R1
;         ${DEBUG} "GotoPath '${XML_PATH}' result: $R1 "
;         ${xml::GetAttribute} "${XML_PARAM}" $XML_VARIABLE $R1
;         ${DEBUG} "GetAttribute '${XML_PARAM}' result '$R1' : $XML_VARIABLE "
    ${xml::SetAttribute} "port" "$XML_VARIABLE" $0
    ${xml::SaveFile} "agent.xml" $0
    ${xml::Unload}
SectionEnd

結果 :

root : agent
GotoPath '/agent' result: 0 
GetAttribute 'port' result '0' : 0000 
于 2012-04-17T12:16:58.667 に答える