You are here

Help in XML modify

11 posts / 0 new
Last post
Pico1965
Offline
Last seen: 2 weeks 6 days ago
Joined: 2006-06-06 12:08
Help in XML modify

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.

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 2 weeks 6 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
XPath?

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

Pico1965
Offline
Last seen: 2 weeks 6 days ago
Joined: 2006-06-06 12:08
Sorry....
Gord Caswell
Gord Caswell's picture
Offline
Last seen: 2 weeks 6 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
Try this

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

Gord Caswell
Gord Caswell's picture
Offline
Last seen: 2 weeks 6 days ago
DeveloperModerator
Joined: 2008-07-24 18:46
Review other apps

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!

Pico1965
Offline
Last seen: 2 weeks 6 days ago
Joined: 2006-06-06 12:08
Thanks for your attention.

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

Pico1965
Offline
Last seen: 2 weeks 6 days ago
Joined: 2006-06-06 12:08
No more help?

No more help?

3D1T0R
3D1T0R's picture
Offline
Last seen: 3 years 3 months ago
Developer
Joined: 2006-12-29 23:48
Did you ever figure out your issue?

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

Devo
Offline
Last seen: 12 months 3 days ago
Joined: 2007-09-04 14:55
Modify XML before or after file move?

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

3D1T0R
3D1T0R's picture
Offline
Last seen: 3 years 3 months ago
Developer
Joined: 2006-12-29 23:48
You're using the wrong Type of FileWrite

Your current code changes the "value" attribute of the "HideSplashScreen" XML node, thus making your settings.xml look like this:

<Settings xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/OutlookGoogleCalendarSync">
    <HideSplashScreen value="true">false</HideSplashScreen>
</Settings>

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 using XML text instead of XML attribute, and the [FileWrite1]:Attribute is no longer needed, thus your FileWrite should look like this:

[FileWrite1]
File=%PAL:DataDir%\settings.xml
Type=XML text
XPath=/Settings/HideSplashScreen
Value=true

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

Devo
Offline
Last seen: 12 months 3 days ago
Joined: 2007-09-04 14:55
That worked perfectly, thanks

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.

Log in or register to post comments