0

我的 NSIS 安装程序正在尝试将一些 XML 添加到现有 XML 文件中。

我的问题:它未能将节点/元素添加到文件中,因为我认为节点/元素内的子元素太多。

如何将此 XML 元素添加到现有 XML 文件中?

注意如果我将字符串 OVERRIDES_TEXT 的长度减少了大约一半,那么代码会正确地将节点添加到 XML 文件中。再长一点,它就会失败。是否可以在 2 go 中写入元素/节点的内容(不是文本,而是子元素)?

${xml::LoadFile} "${xmlFileName}" $R0
${xml::GotoPath} "${elementPath}" $R0
${xml::CreateNode} '<Overrides>${OVERRIDES_TEXT}</Overrides>' $R0
${xml::InsertAfterNode} $R0 $R1  # always fails here $R1 = -1

# below is the string that causes the error
!define OVERRIDES_TEXT "<Override>\
                <Key>EXDS_CUSTOMISATION_REVISION</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>CUSTOMER_USER_4D</Key>\
                <Value>C:\12d\10.00\Customers\EXDS_Customisation\EXDS_User</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>CUSTOMER_LIB_4D</Key>\
                <Value>C:\12d\10.00\Customers\EXDS_Customisation\EXDS_User_Lib</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>USER_4D</Key>\
                <Value>C:\12d\10.00\User</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>USER_LIB_4D</Key>\
                <Value>C:\12d\10.00\User_Lib</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>EXDS_USER_LIB</Key>\
                <Value></Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>EXDS_USER</Key>\
                <Value></Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>VERSION_12D_MODEL</Key>\
                <Value>10.0</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>CPATH</Key>\
                <Value>$$CUSTOMER_LIB_4D:$$CUSTOMER_USER_4D:$$USER_LIB_4D:$$USER_4D:$$LIB_4D:$$SET_UPS_4D</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>AUTHORIZATION_4D</Key>\
                <Value>C:\12d\10.00\nodes.4d</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>USE_NAMES_COMMENT_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>FILE_READ_ADD_TO_VIEW_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>GENIO_WILDCARD_4D</Key>\
                <Value>*.inp</Value>\
                <State>1</State>\
            </Override>\
            <Override>\
                <Key>RUN_MACROS_FILE_4D</Key>\
                <Value>$$USER\macros.4d</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>PROJECT_DETAILS_4D</Key>\
                <Value>$$USER\project_details.dtl</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>REPORT_HEADER_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>AUTO_TIN_SYNC_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>AUTO_MODEL_SYNC_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>SHARE_CHECK_INTERVAL_4D</Key>\
                <Value>300</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>SHARED_ELEMENT_COLOUR_4D</Key>\
                <Value>blue</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>SHARING_ELEMENT_COLOUR_4D</Key>\
                <Value>red</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>DEFAULT_PLAN_PLOT_SCALE_4D</Key>\
                <Value>500</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>DWG_PLOT_SEED_FILE_4D</Key>\
                <Value>$$USER\EXDS_Acad_Plot_Template.dwt</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>DEFAULT_RASTER_DPI_4D</Key>\
                <Value>600</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>OPENGL_VIEW_BACKING_STORE_4D</Key>\
                <Value>2</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>MULTI_LINE_TEXT_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>NEW_MTF_EDITOR_AUTOPAN_DEFAULT_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>WINDOWS_VEHICLE_PATH_4D</Key>\
                <Value>C:\Apps\VPath</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>chainage_equality_4d</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>XML_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>\
            <Override>\
                <Key>USE_V10_BOXING_CALCS_4D</Key>\
                <Value>1</Value>\
                <State>0</State>\
            </Override>"
4

2 回答 2

0

You are probably hitting the NSIS string length limit, try adding one <Override> node at the time with the XML plugin...

于 2012-08-13T10:19:46.043 回答
0

我不确定这种语法是否正确:

${xml::InsertAfterNode} $R0 $R1

难道不是吗

${xml::InsertAfterNode} "$R0" $R1 

?

于 2012-08-13T03:12:45.950 回答