Skip to content
⌘ NSIS Forum Archive

How to write out special character.

4 posts

mcnam_cs#

How to write out special character.

Hi every body,
I have one problem with Install program. I have tried a lot but i can't solve it; I need helping.
My problem is:
In my install script i uses "XML.DLL" plug-in to access ".xml" file. The code is:

xml::LoadFile /NOUNLOAD "$INSTDIR\Config.xml" .r0

xml::CreateNode /NOUNLOAD "<DataPath>M:\M&V\Data</DataPath>" .R0

xml::FindNextElement /NOUNLOAD "ProjectfilePath" .r0 .r1

xml::ReplaceNode /NOUNLOAD "$R0" .r0

xml::SaveFile "$INSTDIR\Config.xml" .r0

i want to set node <DataPath> with the value is M:\M&V\Data but the problem occur with the result. The character "&" can not be appeared in the result.
The result is : M:\MV\Data
I don't know how to write the character "&" output. I have try to use $\&, &amp;, hexa code ... but it still disappeared.
jimpark#
This is an XML issue, not NSIS. The problem is that the & character is a special character. Use &amp;amp; instead. For example:
xml::CreateNode /NOUNLOAD "<DataPath>M:\M&amp;amp;V\Data</DataPath>" .R0
mcnam_cs#
Oh Yes. I had tried that case too. But the result was:<DataPath>M:\M&amp;V\Data</DataPath>.
"&amp;" appeared instead "&". I don't know why.
My xml file is encoded in ANSI; Does it effect the result.
("xml.dll" i'm using is version 1.5)
jimpark#
The fact that you are using ANSI shouldn't matter.

But maybe the text is being parsed twice. So you need something like: &amp;amp;amp;