I need help for modify this xml file:
http://pikky.net/dxs
(image for correct view)
I want modify: RegUserName="" with ciao
My code:
[Activate]
Registry=true
XML=true
[FileWrite7]
File=%PAL:DataDir%\Settings\config.xml
Type=XML attribute
XPath=/config/common_setting/Generic
Attribute=RegUserName
Value=ciao
Not work.
You've cut the image to show only part of the file, so I can't say for sure, however, if you adjust your XPath something like the following, it might work, although depending on the layout of the XML file you may need to be even more specific.:
XPath=/config/common_setting[@CurrentSkin]/Generic
Sorry....
http://pikky.net/sxs
No problem, try this:
[FileWrite7]
File=%PAL:DataDir%\Settings\config.xml
Type=XML attribute
XPath=/config/common_setting[@CurrentSkin="103"]/Generic
Attribute=RegUserName
Value=ciao
When working with XML writing, it may be helpful to review some of the other apps using it.
Scribus Portable, for example, have fairly complex XPath(s) being used in FileWrite5 & FileWrite7 for XML text and XML attribute respectively.
Some others that use it, with varying degrees of complexity, include FreeCol Portable, Inkscape Portable & LMMS Portable.
Hope that helps!
Thanks for your attention.
The online manual is not complete for dealing with XLM.
Just to understand:
/config is the root of xlm
/common_setting is the branch below
[@CurrentSkin="103"] is... the last value on the right of common_ setting branch (the original xlm have many values in common setting branch)
/Generic is the branch that contains the value to be changed.
Question.
If [@CurrentSkin="103"] was a value variable, eg. the position of a window on the monitor as you would to modify it, given that it can not be known at the time of programming?
P.S. Sorry for my bad english
No more help?
Sorry you didn't get everything answered when you were here previously.
Did you figure out a solution to your problem? or are you still facing this issue?
~3D1T0R
I'd just like to build on this a little. I'm trying to modify an XML files as well on the fly. The file is moved by the launcher from the data directory to the app directory. I'm having issues getting the launcher to modify the file because I'm not sure if the code is wrong or if I'm modifying it too late (after it is moved to the app directory). Below is a snippet of the XML file that I'm trying to modify and the code I'm using to do it. Any help would be appreciated.
XML File:
<Settings xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/OutlookGoogleCalendarSync">
<HideSplashScreen>false</HideSplashScreen>
</Settings>
Launcher Code:
[Launch]
ProgramExecutable=OGCS\OutlookGoogleCalendarSync.exe
WorkingDirectory=%PAL:AppDir%\OGCS
[Activate]
XML=true
[FileWrite1]
File=%PAL:DataDir%\settings.xml
Type=XML attribute
XPath=/Settings/HideSplashScreen
Attribute=value
Value=true
[FilesMove]
settings.xml=%PAL:AppDir%\OGCS
OutlookGoogleCalendarSync.exe.config=%PAL:AppDir%\OGCS
*.log=%PAL:AppDir%\OGCS
OGcalsync.log.????-??-??=%PAL:AppDir%\OGCS
Your current code changes the "value" attribute of the "HideSplashScreen" XML node, thus making your settings.xml look like this:
It seems doubtful to me that you intended for that to happen...
If you are instead wanting to set the contents of
/Settings/HideSplashScreen
to "true", your[FileWrite1]:Type
should be usingXML text
instead ofXML attribute
, and the[FileWrite1]:Attribute
is no longer needed, thus your FileWrite should look like this:Finally, don't forget to set
[Activate]:XML=true
, then re-run the PortableApps.com Launcher Generator if you haven't already done so.On a side note, I don't see a good example of how
[FileWriteN]:Type=XML text
works in the PAL manual. Perhaps we should add one to help others with this down the line.~3D1T0R
That worked perfectly, thanks for your help. I do think the XML section in the PAL manual needs some work. I tried several different things before I posted trying to figure out how to use the limited information in the manual to get things to work. At a minimum I think there should be examples in the manual for the different formats of XML files, that's where my confusion was coming from.